一. DataTable转换到List<T> /// <summary> /// TableToList /// </summary> public class TableListConverter<T> where T : class, new() { public static IList<T> TableToList(DataTable dt) { IList<T> ts = new List<T>();// 定义集…
译文出处:http://www.codeproject.com/Tips/867866/Extension-Method-for-Generic-List-Collection-to-Da 这段代码是能够帮助你把泛型集合List转出成DataTable的扩展方法. 背景: 不知道你是否知道这个扩展方法,但是你可以不做任何修改的去使用下面这个类的代码. 使用代码: using System; using System.Collections.Generic; using System.Compon…
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; namespace coDEalers { public static class Extension { public static DataTable ListToDataTable<T>(this IList<T> data, string tableName) { DataTable…