如何在Lightswitch中的SecurityData數據空間中重命名角色的名稱?在Lightswitch中重命名角色
//Lookup the role, and rename it, or create one if none exist.
var rolesQuery = this.DataWorkspace.SecurityData.Roles.Where(r => r.Name.StartsWith(oldRoleNameString)).Execute();
Role role = rolesQuery.Any() ? rolesQuery.Single() : this.DataWorkspace.SecurityData.Roles.AddNew();
role.Name = "OtherName";
,則會引發InvalidOperationException,指出「無法設置屬性‘名稱’的價值,因爲它是隻讀的。」
那麼這樣做的正確方法是什麼?