UserManager<TUser>.AddToRolesAsync 方法

定义

将指定的 user 添加到命名角色。

public:
 virtual System::Threading::Tasks::Task<Microsoft::AspNetCore::Identity::IdentityResult ^> ^ AddToRolesAsync(TUser user, System::Collections::Generic::IEnumerable<System::String ^> ^ roles);
public virtual System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult> AddToRolesAsync (TUser user, System.Collections.Generic.IEnumerable<string> roles);
abstract member AddToRolesAsync : 'User * seq<string> -> System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>
override this.AddToRolesAsync : 'User * seq<string> -> System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>
Public Overridable Function AddToRolesAsync (user As TUser, roles As IEnumerable(Of String)) As Task(Of IdentityResult)

参数

user
TUser

要添加到命名角色的用户。

roles
IEnumerable<String>

要向其添加用户的角色的名称。

返回

表示 Task 异步操作的 ,包含 IdentityResult 操作的 。

适用于