public SiteRole(Role role) { ID = role.ID; Name = role.Name; DisplayName = role.DisplayName; Type = (RoleType)Enum.Parse(typeof(RoleType), Name); AllowedFunction = new HashSet<string>(); foreach (Function func in role.AllowedFunction) { AllowedFunction.Add(func.Name); } }
/// <summary> /// 用于向 Roles EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToRoles(Role role) { base.AddObject("Roles", role); }
/// <summary> /// 创建新的 Role 对象。 /// </summary> /// <param name="id">ID 属性的初始值。</param> /// <param name="name">Name 属性的初始值。</param> /// <param name="displayName">DisplayName 属性的初始值。</param> public static Role CreateRole(global::System.Int32 id, global::System.String name, global::System.String displayName) { Role role = new Role(); role.ID = id; role.Name = name; role.DisplayName = displayName; return role; }