public int Add2 <T>(T model) where T : class, new() { DbSet <T> dst = db2.Set <T>(); dst.Add(model); return(db2.SaveChanges()); }
/// <summary> /// 修改 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Modify <T>(T model) where T : class, new() { using (var db = new BaseDBContent()) { db.Entry(model).State = EntityState.Modified; return(db.SaveChanges()); } }
/// <summary> /// 删除 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Del <T>(T model) where T : class, new() { using (var db = new BaseDBContent()) { db.Set <T>().Attach(model); db.Set <T>().Remove(model); return(db.SaveChanges()); } }
/// <summary> /// 增加 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Add <T>(T model) where T : class, new() { using (var db = new BaseDBContent()) { DbSet <T> dst = db.Set <T>(); dst.Add(model); return(db.SaveChanges()); } }