完整DataTable与IList互换(转)】的更多相关文章

public class CollectionHelper { private CollectionHelper() { } public static DataTable ConvertTo<T>(IList<T> list) { DataTable table = CreateTable<T>(); Type entityType = typeof(T); PropertyDescriptorCollection properties = TypeDescripto…
将DataTable集合反射获取 List<M> /// <summary> /// 根据DataTable集合反射获取 List<M> /// </summary> /// <typeparam name="M">泛型实体</typeparam> /// <param name="dt">DataTable</param> /// <returns>实体集合…
IList转DataTable.DataTable转IList using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Linq; using System.Reflection; using System.Text; namespace Framework.Utility { public static class DataTable…
前文介绍了Winform为DataGridView提供的数据自动绑定功能,下面介绍一下采用代码的数据绑定 1.用DataSet和DataTable为DataGridView提供数据源 先上代码 private void Form1_Load(object sender, EventArgs e) { String strConn = "Data Source=210.26.*.*;Initial Catalog=Test;User ID=sa;Password=*****"; SqlC…
public static class List2DataTable { #region "Convert Generic List to DataTable" /// <summary> /// Convert a List{T} to a DataTable. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="i…
DataTable GroupBy的用法 var result = dt.AsEnumerable(). GroupBy(g => new { StaffID = g.Field<string>("StaffID"), StaffName = g.Field<string>("StaffName"), ActivityDate = g.Field<string>("ActivityDate") }). S…
微软的Excel操作类导出Excel会很慢,此方法简单的把表中内容以字符串的形式写入到Excel中,用到的一个技巧就是"\t". C#中的\t相当于Tab键,写入到Excel中时就是一列一列中写入. #region 导出Excel public void WriteExcel(DataTable ds, string path) { long totalCount = ds.Rows.Count; Thread.Sleep(1000); long rowRead = 0; float…
public IList GetModelList(string tablename, string where) { IList list = null; DataTable dataTable = new DataTable(); string sql = "select * from " + tablename; if (where != "") { sql += " Where " + where; } try { System.Data…
List<info> infos = Dal.GetInfos(); DataTable dt = new DataTable(); dt.Columns.Add("cName"); foreach (var info in infos) { DataRow dr = dt.NewRow(); dr["cName"] = info.Name; dt.Add(dr); } public static class DataTableExtensions {…
//来源:http://www.cnblogs.com/yuangang/p/5477324.html using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Net; using System.Web; using System.Security.Cryptography; using System.Text.Regul…