public static TObject Find <TObject>(int id) where TObject : class { using (var ctx = new AccountingSystem()) { return(ctx.Set <TObject>().Find(id)); } }
public static int Update <TObject>(TObject obj) where TObject : class { using (var ctx = new AccountingSystem()) { ctx.Set(typeof(TObject)).Attach(obj); ctx.Entry(obj).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); return(0); } }
public static int Add <TEntity>(TEntity entity) { using (var ctx = new AccountingSystem()) { //entity.cuid = LogTracker.GetLoggedUser().FullName; //entity.MakeCreated(); ctx.Set(typeof(TEntity)).Add(entity); ctx.SaveChanges(); return(0); } }