(原文地址:http://xuzhihong1987.blog.163.com/blog/static/26731587201101853740294/) LINQ查询返回DataTable类型 在使用LINQ查询的时候,一般我们会返回List<T>或IList<T>类型,如下所示: 例1: public List<TSample> GetList() { using (BPDataContext db = newBPDataContext(TCTC_Connectio
/// <summary> /// 将DataTable转成Model /// </summary> /// <param name="dt"></param> /// <returns></returns> public class ModelConvertHelper<T> where T : new() { public static List<T> ConvertToModel(Da
public List<T> ConvertToList<T>(DataTable dt) where T : new() { // 定义集合 List<T> ts = new List<T>(); // 获得此模型的类型 Type type = typeof(T); string tempName = "";