public class DtConvertToList<T> where T : new() { /// <summary> /// 实体转换辅助类 /// </summary> public static List<T> ConvertToModel(DataTable dt) { // 定义集合 List<T> ts = new List<T>(); // 获得此模型的类型 Type type = typeof(T); stri…
public static class DataTableToEntity { /// <summary> /// 将DataTable数据源转换成实体类 /// </summary> public static List<T> ConvertToModel<T>(this DataTable dt) where T : new() { List<T> ts = new List<T>();// 定义集合 foreach (DataR…
using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Linq; using System.Reflection; using System.Text; using System.Text.RegularExpressions; namespace IBO.XJMYQP.Utility { public static class Exten…
/// <summary> /// 实体转换辅助类 /// </summary> public class ModelConvertHelper<T> where T : new() { /// <summary> /// List泛型转换DataTable. /// </summary> public DataTable ListToDataTable<T>(List<T> items) { var tb = new D…
最近在修改维护以前的webform项目(维护别人开发的.....)整个aspx没有用到任何的控件,这个我也比较喜欢不用控件所以在提交信息的时候需要自己手动的去Request.QueryString[]或者Request.Form[]去获取,转型,判定等等觉得这样子的代码写多了不甚其烦,就在想能不能自动获取,解析这些参数成我需要的数据实体呢,当然是可以的这里我用反射根据参数的Key与实体的PropertyName进行对比,类型转换赋值给实体 public static T NameValues2E…