public bool AddRole(string roleName, string memo, bool islock) { using (AuthorizeEntities context = new AuthorizeEntities()) { try { var roleAdd = new Role(); roleAdd.RoleID = Guid.NewGuid(); roleAdd.RoleName = roleName; roleAdd.IsLock = islock; roleAdd.Memo = memo; context.AddToRole(roleAdd); context.SaveChanges(); return true; } catch (Exception e) { throw e; } } }
/// <summary> /// 用于向 Role EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToRole(Role role) { base.AddObject("Role", role); }
/// <summary> /// 创建新的 Role 对象。 /// </summary> /// <param name="roleID">RoleID 属性的初始值。</param> /// <param name="roleName">RoleName 属性的初始值。</param> /// <param name="isLock">IsLock 属性的初始值。</param> public static Role CreateRole(global::System.Guid roleID, global::System.String roleName, global::System.Boolean isLock) { Role role = new Role(); role.RoleID = roleID; role.RoleName = roleName; role.IsLock = isLock; return role; }