Beispiel #1
0
        public int Add2 <T>(T model) where T : class, new()
        {
            DbSet <T> dst = db2.Set <T>();

            dst.Add(model);
            return(db2.SaveChanges());
        }
Beispiel #2
0
 /// <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());
     }
 }
Beispiel #3
0
 /// <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());
     }
 }
Beispiel #4
0
 /// <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());
     }
 }