/// <summary> /// 创建菜单 /// </summary> /// <param name="entity">菜单</param> /// <returns></returns> public int CreateMenu(Menu entity) { using (DBContainer db = new DBContainer()) { db.Menu.AddObject(entity); return db.SaveChanges(); } }
/// <summary> /// 创建新的 Menu 对象。 /// </summary> /// <param name="menu_Id">Menu_Id 属性的初始值。</param> /// <param name="menuGroup_Id">MenuGroup_Id 属性的初始值。</param> /// <param name="modelId">ModelId 属性的初始值。</param> /// <param name="name">Name 属性的初始值。</param> public static Menu CreateMenu(global::System.String menu_Id, global::System.String menuGroup_Id, global::System.String modelId, global::System.String name) { Menu menu = new Menu(); menu.Menu_Id = menu_Id; menu.MenuGroup_Id = menuGroup_Id; menu.ModelId = modelId; menu.Name = name; return menu; }
/// <summary> /// 用于向 Menu EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToMenu(Menu menu) { base.AddObject("Menu", menu); }
/// <summary> /// 更新菜单 /// </summary> /// <param name="entity">菜单</param> /// <returns></returns> public int EditMenu(Menu entity) { using (DBContainer db = new DBContainer()) { db.Menu.Attach(entity); db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); return db.SaveChanges(); } }