/// <summary> /// DataReader到Collection /// </summary> /// <typeparam name="T"></typeparam> /// <param name="collection"></param> /// <param name="dr"></param> /// <param name="items"></param> /// <param name="dod"></param> /// <returns>返回原有的集合</returns> public static EditableDataObjectCollectionBase <T> DataReaderToCollection <T>(EditableDataObjectCollectionBase <T> collection, IDataReader dr, ORMappingItemCollection items, DataToObjectDeligations dod) where T : new() { dr.NullCheck("dr"); items.NullCheck("items"); dod.NullCheck("dod"); using (ORMappingContext context = ORMappingContext.GetContext()) { while (dr.Read()) { collection.Add(DataReaderToObject(dr, items, new T(), dod)); } } return(collection); }
/// <summary> /// DataReader到Collection /// </summary> /// <typeparam name="T"></typeparam> /// <param name="collection"></param> /// <param name="dr"></param> /// <param name="items"></param> /// <param name="dod"></param> public static void DataReaderToCollection <T>(EditableDataObjectCollectionBase <T> collection, IDataReader dr, ORMappingItemCollection items, DataToObjectDeligations dod) where T : new() { dr.NullCheck("dr"); items.NullCheck("items"); dod.NullCheck("dod"); using (ORMappingContext context = ORMappingContext.GetContext()) { while (dr.Read()) { T graph = new T(); DataReaderToObject(dr, items, graph, dod); collection.Add(graph); } } }