/// <summary> /// 创建一个实体 /// </summary> /// <param name="entity">实体</param> /// <returns></returns> public int Create(Entity.SysSample entity) { using (DBContainer db = new DBContainer()) { db.SysSample.AddObject(entity); return db.SaveChanges(); } }
/// <summary> /// 创建一个对象 /// </summary> /// <param name="db">数据库</param> /// <param name="entity">实体</param> public int Create(SysLog entity) { using (DBContainer db = new DBContainer()) { db.SysLog.AddObject(entity); return db.SaveChanges(); } }
/// <summary> /// 新增系统功能 /// </summary> /// <param name="entity">系统功能</param> /// <returns></returns> public int CreateSysFunction(Entity.SysFunction entity) { using (DBContainer db = new DBContainer()) { db.SysFunction.AddObject(entity); return db.SaveChanges(); } }
/// <summary> /// 创建菜单组 /// </summary> /// <param name="entity">菜单组</param> /// <returns></returns> public int CreateMenuGroup(MenuGroup entity) { using (DBContainer db = new DBContainer()) { db.MenuGroup.AddObject(entity); return db.SaveChanges(); } }
/// <summary> /// 更新一个实体 /// </summary> /// <param name="entity">实体</param> /// <returns></returns> public int Edit(Entity.SysSample entity) { using (DBContainer db = new DBContainer()) { db.SysSample.Attach(entity); db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); return db.SaveChanges(); } }
/// <summary> /// 删除一个实体 /// </summary> /// <param name="id">id</param> /// <returns></returns> public int Delete(string id) { using (DBContainer db = new DBContainer()) { var entity = db.SysSample.SingleOrDefault(p => p.Id.Equals(id)); if (entity != null) { db.SysSample.DeleteObject(entity); } return db.SaveChanges(); } }
/// <summary> /// 删除菜单组 /// </summary> /// <param name="id">菜单组Id</param> /// <returns></returns> public int DeleteMenuGroup(string id) { using (DBContainer db = new DBContainer()) { var entity = db.MenuGroup.SingleOrDefault(p => p.MenuGroup_Id.Equals(id, StringComparison.CurrentCultureIgnoreCase)); if (entity != null) db.MenuGroup.DeleteObject(entity); return db.SaveChanges(); } }
/// <summary> /// 更新菜单组 /// </summary> /// <param name="entity">菜单组</param> /// <returns></returns> public int EditMenuGroup(MenuGroup entity) { using (DBContainer db = new DBContainer()) { db.MenuGroup.Attach(entity); db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); return db.SaveChanges(); } }