ilist转换dataset
using System.Collections.Generic;
/// <summary>
/// Class1 鐨勬憳瑕佽鏄?
/// </summary>
namespace Flowers.Web
{
public class NHibernateHelper
{
/**/
/// <summary>
/// Ilist <T> 杞崲鎴?DataSet
/// </summary>
/// <param name= "list "> </param>
/// <returns> </returns>
public static DataSet ConvertToDataSet <T> (IList <T> list)
{
if (list == null || list.Count <= 0)
{
return null;
}
DataSet ds = new DataSet();
DataTable dt = new DataTable(typeof(T).Name);
DataColumn column;
DataRow row;
System.Reflection.PropertyInfo[] myPropertyInfo = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
foreach (T t in list)
{
if (t == null)
{
continue;
}
row = dt.NewRow();
for (int i = 0