public virtual T Create <T>(T model) where T : DbObject, new() { IDbObjectInfo <T> dbObjectInfo = this.DbRuleContext.GetDbObjectInfo <T>(); model = dbObjectInfo.CreateClone(this, model); dbObjectInfo.CheckDuplicate(this, model, new string[0]); dbObjectInfo.SetModifyDatetime(model); this.Validate <T>(model, DbOperation.Create); this.DbObjectOperator.Insert(model); return(model); }
public void Delete <T>(T model) where T : DbObject, new() { IDbObjectInfo <T> dbObjectInfo = this.DbRuleContext.GetDbObjectInfo <T>(); if (dbObjectInfo.IsLogicalDelete) { T local = dbObjectInfo.RemoveClone(this, model); if (local != null) { dbObjectInfo.SetModifyDatetime(local); this.Validate <T>(model, DbOperation.None | DbOperation.Update); this.DbObjectOperator.Update(local); } } else { dbObjectInfo.SetModifyDatetime(model); this.Validate <T>(model, DbOperation.Delete); this.DbObjectOperator.Delete(model); } }
public virtual T Update <T>(T model) where T : DbObject, new() { IDbObjectInfo <T> dbObjectInfo = this.DbRuleContext.GetDbObjectInfo <T>(); dbObjectInfo.CheckDuplicate(this, model, new string[0]); T local = dbObjectInfo.UpdateClone(this, model, new string[0]); this.Validate <T>(local, DbOperation.None | DbOperation.Update); dbObjectInfo.SetModifyDatetime(local); this.DbObjectOperator.Update(local); return(local); }
public void Delete <T>(string id) where T : DbObject, new() { IDbObjectInfo <T> dbObjectInfo = this.DbRuleContext.GetDbObjectInfo <T>(); DynamicPropertyInfo pkDynamicPropertyInfo = DbObjectTools.GetPkDynamicPropertyInfo(DbObjectTools.GetDbObjectInfo(typeof(T)), true); T model = this.QueryObject <T>(pkDynamicPropertyInfo.DataFieldName, id, true); dbObjectInfo.SetModifyDatetime(model); if (dbObjectInfo.IsLogicalDelete) { dbObjectInfo.SetLogicalDelete(model); this.DbObjectOperator.Update(model); } else { this.DbObjectOperator.Delete(model); } }