Ejemplo n.º 1
0
 /// <summary>
 /// 添加单位实体
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public int Add(BusiUnit entity)
 {
     try
     {
         dbContext.BusiUnit.Add(entity);
         return(dbContext.SaveChanges());
     }
     catch
     {
         throw new Exception();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据id删除实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeleteBusiUnitById(int id)
        {
            try
            {
                BusiUnit unit = new BusiUnit()
                {
                    BusiUnitId = id
                };

                BusiUnit entity = dbContext.BusiUnit.Attach(unit);
                dbContext.BusiUnit.Remove(entity);
                return(dbContext.SaveChanges());
            }
            catch (Exception e)
            {
                throw e;
            }
        }