protected virtual PetaPocoDatabase CreateDAO() { if (this.Database == null) { this.Database = PetaPocoDatabase.CreateInstance(null); } return(this.Database); }
public virtual void Update(TEntity entity) { PetaPocoDatabase petaPocoDatabase = this.CreateDAO(); if (entity is ISerializableProperties) { ISerializableProperties serializableProperties = entity as ISerializableProperties; if (serializableProperties != null) { serializableProperties.Serialize(); } } int num; if (Repository <TEntity> .RealTimeCacheHelper.PropertyNameOfBody != null && Repository <TEntity> .RealTimeCacheHelper.PropertyNameOfBody.GetValue(entity, null) == null) { Database.PocoData pocoData = PetaPoco.Database.PocoData.ForType(typeof(TEntity)); System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>(); foreach (System.Collections.Generic.KeyValuePair <string, Database.PocoColumn> current in pocoData.Columns) { if (string.Compare(current.Key, pocoData.TableInfo.PrimaryKey, true) != 0 && (SqlBehaviorFlags.Update & current.Value.SqlBehavior) != (SqlBehaviorFlags)0 && string.Compare(current.Key, Repository <TEntity> .RealTimeCacheHelper.PropertyNameOfBody.Name, true) != 0 && !current.Value.ResultColumn) { list.Add(current.Key); } } num = petaPocoDatabase.Update(entity, list); } else { num = petaPocoDatabase.Update(entity); } if (num > 0) { this.OnUpdated(entity); } }