public virtual void InsertAndHydrate <T>(T toCreate, Dictionary <string, object> constructorParameters) where T : IMapsDirectlyToDatabaseTable { NextObjectId++; toCreate.ID = NextObjectId; foreach (KeyValuePair <string, object> kvp in constructorParameters) { var val = kvp.Value; //don't set nulls if (val == DBNull.Value) { val = null; } var prop = toCreate.GetType().GetProperty(kvp.Key); var strVal = kvp.Value as string; SetValue(toCreate, prop, strVal, val); } toCreate.Repository = this; Objects.Add(toCreate); toCreate.PropertyChanged += toCreate_PropertyChanged; NewObjectPool.Add(toCreate); }
public void InsertAndHydrate <T>(T toCreate, Dictionary <string, object> constructorParameters) where T : IMapsDirectlyToDatabaseTable { int id = InsertAndReturnID <T>(constructorParameters); var actual = GetObjectByID <T>(id); //.Repository does not get included in this list because it is [NoMappingToDatabase] foreach (PropertyInfo prop in GetPropertyInfos(typeof(T))) { prop.SetValue(toCreate, prop.GetValue(actual)); } toCreate.Repository = actual.Repository; NewObjectPool.Add(toCreate); }
public void Dispose() { Objects.Clear(); NewObjectPool.EndSession(); }