开发者

export data set to csv file using C#

how to export Data from sql s开发者_如何学Cerver into csv file using c#

Eg;

Select name,id from employee

Name id

XXX 1 ZZZ 2 AAA 3

This result will be stored in the CSV File.


Using Filehelpers and Dapper.

[DelimitedRecord(",")] 
public class Employee 
{ 
    public string Name;
    public int Id; 
}

In some method somewhere:

var employees = connection.Query<Employee>("select Name, Id from employee");
FileHelperEngine engine = new FileHelperEngine(typeof(Employee));
engine.WriteFile("employees.csv", employees);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜