public static bool SetModelValue(SqlDataReader dataReader, Object obj) { if (!dataReader.HasRows) { return(false); } dataReader.Read(); List <PropertyAttribute> attributes = ORMUtils.GetFieldAttributes(obj); foreach (PropertyAttribute item in attributes) { SetFieldValue(obj, item.Property, dataReader[item.Property.Name]); } dataReader.Close(); return(true); }
public static List <T> SetModelListValue <T>(SqlDataReader dataReader) where T : ORMSupport, new() { List <T> list = new List <T>(); if (!dataReader.HasRows) { return(list); } while (dataReader.Read()) { T t = new T(); List <PropertyAttribute> attributes = ORMUtils.GetFieldAttributes(t); foreach (PropertyAttribute attr in attributes) { SetFieldValue(t, attr.Property, dataReader[attr.Property.Name]); } list.Add(t); } return(list); }