码迷,mamicode.com
首页 > 其他好文 > 详细

DataTable List 相互转换

时间:2018-03-11 19:13:45      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:https   col   can   github   des   pre   datarow   max   tab   

This uses the FastMember‘s meta-programming API for maximum performance. If you want to restrict it to particular members (or enforce the order), then you can do that too:
IEnumerable<SomeType> data = ...
DataTable table = new DataTable();
using(var reader = ObjectReader.Create(data, "Id", "Name", "Description")) {
    table.Load(reader);
}
使用类库: https://github.com/mgravell/fast-member
var list = dataTable.Rows.OfType<DataRow>()
    .Select(dr => dr.Field<string>(columnName)).ToList();

需引用:System.Data.DataSetExtensions

DataTable List 相互转换

标签:https   col   can   github   des   pre   datarow   max   tab   

原文地址:https://www.cnblogs.com/MuNet/p/8544928.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!