如何使用c#
将数据从sql server导出到csv文件中例如
选择姓名,来自员工的身份
名称ID
XXX 1 ZZZ 2 AAA 3
此结果将存储在CSV文件中。
答案 0 :(得分:7)
[DelimitedRecord(",")]
public class Employee
{
public string Name;
public int Id;
}
某处某处方法:
var employees = connection.Query<Employee>("select Name, Id from employee");
FileHelperEngine engine = new FileHelperEngine(typeof(Employee));
engine.WriteFile("employees.csv", employees);