using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Dynamic; public static class HelperExtensions { public static List<dynamic> ToDynamic(this DataTable dt) { var dynamicDt = new List&…
public class DataConvert { public static List<T> ConvertDataTable<T>(DataTable dt) { List<T> data = new List<T>(); foreach (DataRow row in dt.Rows) { T item = GetItem<T>(row); data.Add(item); } return data; } public static T…
First of all, we have to fetch the records from the database (MS Sqlserver) into the C# DataTable, or we can add dynamic rows to our DataTable. So our code looks like as written below. //* public DataTable getData() { DataTable dt = new DataTable();…
using System; using System.Data; using System.Configuration; using System.Collections; using System.Collections.Generic; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControl…
很简单的转换功能,这是我在GitHub上复制的一段代码(懒得再去找原地址了),感觉功能还算可以,贴出来分享给大家 /// <summary> /// DataTable to List converter generic class. /// Convert DataTable to a specific class List<>. /// The Class Property Name must be same as the Column Name of the DataTabl…