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);
精彩评论