实体类转换成DateTable,
来源:互联网 发布:智慧校园网络建设方案 编辑:程序博客网 时间:2024/06/07 06:38
/// <summary> /// 实体类转换成DataTable /// </summary> /// <param name="modelList">实体类列表</param> /// <returns></returns> public DataTable FillDataTable(List<ProductImageInfo> modelList) { if (modelList == null || modelList.Count == 0) { return null; } DataTable dt = CreateData(modelList[0]); foreach (ProductImageInfo model in modelList) { DataRow dataRow = dt.NewRow(); foreach (PropertyInfo propertyInfo in typeof(ProductImageInfo).GetProperties()) { dataRow[propertyInfo.Name] = propertyInfo.GetValue(model, null); } dt.Rows.Add(dataRow); } return dt; } /// <summary> /// 根据实体类得到表结构 /// </summary> /// <param name="model">实体类</param> /// <returns></returns> private DataTable CreateData(ProductImageInfo model) { DataTable dataTable = new DataTable(typeof(ProductImageInfo).Name); foreach (PropertyInfo propertyInfo in typeof(ProductImageInfo).GetProperties()) { dataTable.Columns.Add(new DataColumn(propertyInfo.Name, propertyInfo.PropertyType)); } return dataTable; }
0 0
- 实体类转换成DateTable,
- c# 将实体类集合转化为datetable格式案例
- DateTable转换为List泛型
- DataRow转换成实体类
- 数据行转换成实体类
- 泛型加反射 DataTable转换成实体类
- Json数据转换成实体类
- 实体类转换
- C#中将JSon数据转换成实体类,将实体类转换成Json
- 把sharepoint list转化成DateTable
- C# 将 Json 解析成 DateTable
- 实体数组转换成DataTable
- 实体类 动态转换 DataSet
- 实体类转换-映射EntityConverter
- springmvc实体类类型转换
- 数据实体转换工具类
- SolrDocument与实体类转换
- 如何将JSON转换成实体类集合?
- 42. Trapping Rain Water
- Android Studio导入github项目详解
- 6.OpenFlow信道与控制信道 OpenFlow1.5核心概念翻译与理解-OpenFlow1.5中文版
- PHP 生成4位数,不足前面补0
- JNI 在native方法中打印日志
- 实体类转换成DateTable,
- @RequestParam、@RequestBody、@PathVariable 等注解详解
- SSH配置与SecureCRT设置
- Nginx------Nginx启动、停止与信号控制
- spring boot 使用application.properties 进行外部配置
- ThreadLocal详解
- 最近开发的基于Excel的考试系统---VBA
- HDU 1021 Fibonacci Again 水题 优化
- android硬件访问服务程序框架和简单实例分析