public static void Fill<T>(IDataReader sdr, T entity)
{
for (int i = 0; i < sdr.FieldCount; i++)
{
PropertyInfo pi = entity.GetType().GetProperty(sdr.GetName(i));
if (pi != null)
{
if (sdr.GetValue(i) != DBNull.Value)
{
pi.SetValue(entity, sdr.GetValue(i), null);
}
}
}
}
public static IList<T> EnumDataReader<T>( IDataReader idr)
{
IList<T> IL = new List<T>();
while (idr.Read())
{
T entiy = Activator.CreateInstance<T>();
Fill<T>(idr,entiy);
IL.Add(entiy);
}
return IL;
}
{
for (int i = 0; i < sdr.FieldCount; i++)
{
PropertyInfo pi = entity.GetType().GetProperty(sdr.GetName(i));
if (pi != null)
{
if (sdr.GetValue(i) != DBNull.Value)
{
pi.SetValue(entity, sdr.GetValue(i), null);
}
}
}
}
public static IList<T> EnumDataReader<T>( IDataReader idr)
{
IList<T> IL = new List<T>();
while (idr.Read())
{
T entiy = Activator.CreateInstance<T>();
Fill<T>(idr,entiy);
IL.Add(entiy);
}
return IL;
}