哪位帮帮忙!

解决方案 »

  1.   

    将 Ilist 转换成 DataSet 注: iList: 数据源     className: 类完全限定名     DllFile:className 所属的程序集名 如 :SysGUI.QdcLib.dll         public DataSet ConvertIListToDataSet(IListiList, stringclassName, stringDllFile)         {             Type TheType = null;             if (DllFile != "")             {                 Assembly Assembly1 = Assembly.LoadFrom(DllFile);                  TheType = Assembly1.GetType(className);             }             else             {                 TheType = Type.GetType(className);             }             string sTableName = NHibernate.Cfg.ImprovedNamingStrategy.Instance.ClassToTableName(className);             BindingFlags bindFlag = BindingFlags.Public | BindingFlags.Instance;             PropertyInfo[] pInfos = TheType.GetProperties(bindFlag);             DataSet dSet = newDataSet();             DataTable dTable = dSet.Tables.Add(sTableName);             string strColmunName ="";             foreach (PropertyInfoinfoinpInfos)             {                 strColmunName = NHibernate.Cfg.ImprovedNamingStrategy.Instance.PropertyToColumnName(info.Name);                 dTable.Columns.Add(strColmunName, info.PropertyType.GetType());             }               foreach(objectobjiniList){                 DataRow dRow = dTable.NewRow();                 foreach(PropertyInfoinfoinpInfos){                     strColmunName = NHibernate.Cfg.ImprovedNamingStrategy.Instance.PropertyToColumnName(info.Name);                     dRow[strColmunName] = info.GetValue(obj, null);                 }                 dTable.Rows.Add(dRow);             }             return dSet;         }