public TObjectType AddNew() { TObjectType obj = CSObject <TObjectType> .New(); Add(obj); return(obj); }
private List <TObjectType> GetObjects(string sqlQuery, CSParameterCollection parameters, Dictionary <string, string> aliasMap, IEnumerable <PrefetchField> prefetchFields) { using (CSTransaction csTransaction = new CSTransaction(Schema)) { List <TObjectType> objectList = new List <TObjectType>(); using (ICSDbReader reader = DB.CreateReader(sqlQuery, parameters)) { while (reader.Read()) { TObjectType csObject = CSObject <TObjectType> .New(); csObject.Fire_ObjectReading(); csObject.FromDataReader(reader, aliasMap); foreach (PrefetchField prefetchField in prefetchFields) { csObject.ReadRelationToOne(prefetchField.SchemaField, reader, prefetchField.AliasMap); } if (FilterPredicate != null) { bool shouldAdd = true; foreach (Predicate <TObjectType> predicate in FilterPredicate.GetInvocationList()) { if (!predicate(csObject)) { shouldAdd = false; break; } } if (!shouldAdd) { continue; } } csObject.ObjectDeleted += OnObjectDeleted; objectList.Add(csObject); csObject.Fire_ObjectRead(); } } csTransaction.Commit(); return(objectList); } }