/// <summary>
 /// 创建一个部门
 /// </summary>
 /// <param name="db">实体数据</param>
 /// <param name="entity">将要创建的一个部门</param>
 public void Create(SysEntities db, SysDepartment entity)
 {
     if (entity != null)
     {
         db.SysDepartment.AddObject(entity);
     }
 }
 /// <summary>
 /// 创建一个部门
 /// </summary>
 /// <param name="entity">一个对象</param>
 /// <returns></returns>
 public int Create(SysDepartment entity)
 {
     using (SysEntities db = new SysEntities())
     {
         Create(db, entity);
         return(this.Save(db));
     }
 }
        /// <summary>
        /// 删除一个部门
        /// </summary>
        /// <param name="db">实体数据</param>
        /// <param name="id">一条部门的主键</param>
        public void Delete(SysEntities db, string id)
        {
            SysDepartment deleteItem = GetById(db, id);

            if (deleteItem != null)
            {
                db.SysDepartment.DeleteObject(deleteItem);
            }
        }
 /// <summary>
 /// 编辑一个部门对象
 /// </summary>
 /// <param name="db">实体数据</param>
 /// <param name="entity">将要编辑的一个部门对象</param>
 public SysDepartment Edit(SysEntities db, SysDepartment entity)
 {
     db.SysDepartment.Attach(entity);
     db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
     return(entity);
 }