/// <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(); } }
/// <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; } }