| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Data;
 
- using System.Reflection;
 
- using SCC.Common;
 
- namespace SCC.Services
 
- {
 
-     
 
-     
 
-     
 
-     public class BaseServices
 
-     {
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         protected T LoadData<T>(DataRow dr)
 
-         {
 
-             if (dr == null) return default(T);
 
-             var t = typeof(T);
 
-             var obj = Activator.CreateInstance(t);
 
-             var properts = t.GetProperties();
 
-             foreach (var pi in properts)
 
-             {
 
-                 if (!dr.Table.Columns.Contains(pi.Name)) continue;
 
-                 pi.SetValue(obj, CommonHelper.ChangeType(dr[pi.Name], pi.PropertyType), null);
 
-             }
 
-             return (T)obj;
 
-         }
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         protected List<T> LoadDataList<T>(DataTable dt)
 
-         {
 
-             List<T> result = new List<T>();
 
-             var t = typeof(T);
 
-             var properts = t.GetProperties();
 
-             object obj;
 
-             foreach (DataRow dr in dt.Rows)
 
-             {
 
-                 obj = Activator.CreateInstance(t);
 
-                 foreach (var pi in properts)
 
-                 {
 
-                     if (!dt.Columns.Contains(pi.Name)) continue;
 
-                     pi.SetValue(obj, CommonHelper.ChangeType(dr[pi.Name], pi.PropertyType), null);
 
-                 }
 
-                 result.Add((T)obj);
 
-             }
 
-             return result;
 
-         }
 
-     }
 
- }
 
 
  |