public int Create(SysModule entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.SysModules.AddObject(entity);
         return db.SaveChanges();
     }
 }
 public int Edit(SysModule entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.SysModules.Attach(entity);
         db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
         return db.SaveChanges();
     }
 }
 public bool Create(ref ValidationErrors errors, SysModuleModel model)
 {
     try
     {
         SysModule entity = m_Rep.GetById(model.Id);
         if (entity != null)
         {
             errors.Add(Suggestion.PrimaryRepeat);
             return false;
         }
         entity = new SysModule();
         entity.Id = model.Id;
         entity.Name = model.Name;
         entity.EnglishName = model.EnglishName;
         entity.ParentId = model.ParentId;
         entity.Url = model.Url;
         entity.Iconic = model.Iconic;
         entity.Sort = model.Sort;
         entity.Remark = model.Remark;
         entity.Enable = model.Enable;
         entity.CreatePerson = model.CreatePerson;
         entity.CreateTime = model.CreateTime;
         entity.IsLast = model.IsLast;
         if (m_Rep.Create(entity) == 1)
         {
             //分配给角色
             dbContainer.P_Sys_InsertSysRight();
             return true;
         }
         else
         {
             errors.Add(Suggestion.InsertFail);
             return false;
         }
     }
     catch (Exception ex)
     {
         errors.Add(ex.Message);
         ExceptionHander.WriteException(ex);
         return false;
     }
 }
 /// <summary>
 /// 创建新的 SysModule 对象。
 /// </summary>
 /// <param name="id">Id 属性的初始值。</param>
 /// <param name="name">Name 属性的初始值。</param>
 /// <param name="isLast">IsLast 属性的初始值。</param>
 /// <param name="enable">Enable 属性的初始值。</param>
 public static SysModule CreateSysModule(global::System.String id, global::System.String name, global::System.Boolean isLast, global::System.Boolean enable)
 {
     SysModule sysModule = new SysModule();
     sysModule.Id = id;
     sysModule.Name = name;
     sysModule.IsLast = isLast;
     sysModule.Enable = enable;
     return sysModule;
 }
 /// <summary>
 /// 用于向 SysModules EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToSysModules(SysModule sysModule)
 {
     base.AddObject("SysModules", sysModule);
 }