Пример #1
0
        public void Delete(int ID)
        {
            OAEntities enty = new OAEntities();

            var user = enty.Users.Where(a => a.Id == ID).FirstOrDefault();

            enty.Entry(user).State = System.Data.EntityState.Deleted;

            int row = enty.SaveChanges();

            Response.Write(row);
            Response.End();
        }
Пример #2
0
 /// <summary>
 ///增加
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public T AddEntity(T entity)
 {
     Db.Set <T>().Add(entity);
     Db.SaveChanges();
     return(entity);
 }
Пример #3
0
 /// <summary>
 /// 一个业务中可能涉及到对多张表的操作,那么可以将操作的数据传递到数据层中相应的方法。
 /// </summary>
 /// <returns></returns>
 public bool SaveChange()
 {
     return(Db.SaveChanges() > 0);
 }