資源簡介
將datatable 轉換成實體類 例子源碼下載(GhExcel)
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Data;
using?System.Reflection;
/**
?*?作者:黃炳桂
?*?Email:516821420@qq.com
?*/
namespace?GhOrm
{
????public?class?GhConvert?where?T?:?new()
????{
????????///?
????????///?將DataTable轉換成Model實體
????????///?
????????///?Model名稱
????????///?DataTable
????????///?
????????public?static?T?Toobject(DataTable?dt)
????????{
????????????if?(dt.Rows.Count?<=?0)?return?new?T();
????????????T?t?=?new?T();
????????????string?tempName?=?““;
????????????PropertyInfo[]?pis?=?t.GetType().GetProperties();
????????????foreach?(PropertyInfo?pi?in?pis)
????????????{
????????????????tempName?=?pi.Na
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????7844??2015-01-27?15:02??GhConvert.cs
?????文件???????1934??2015-01-27?15:03??GhExcel.cs
-----------?---------??----------?-----??----
?????????????????9778????????????????????2
- 上一篇:c#html 保存pdf
- 下一篇:c# 多線程學習
評論
共有 條評論