UserStore<TUser,TRole,TContext,TKey,TUserClaim,TUserRole,TUserLogin,TUserToken,TRoleClaim>.FindByIdAsync 方法

定义

查找并返回具有指定 userId的用户(如果有)。

public virtual System.Threading.Tasks.Task<TUser> FindByIdAsync (string userId, System.Threading.CancellationToken cancellationToken = default);
public override System.Threading.Tasks.Task<TUser> FindByIdAsync (string userId, System.Threading.CancellationToken cancellationToken = default);
public override System.Threading.Tasks.Task<TUser?> FindByIdAsync (string userId, System.Threading.CancellationToken cancellationToken = default);
abstract member FindByIdAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'User (requires 'User :> Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<'Key, 'UserClaim, 'UserRole, 'UserLogin>)>
override this.FindByIdAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'User (requires 'User :> Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<'Key, 'UserClaim, 'UserRole, 'UserLogin>)>
override this.FindByIdAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'User (requires 'User :> Microsoft.AspNetCore.Identity.IdentityUser<'Key>)>
Public Overridable Function FindByIdAsync (userId As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TUser)
Public Overrides Function FindByIdAsync (userId As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TUser)

参数

userId
String

要搜索的用户 ID。

cancellationToken
CancellationToken

CancellationToken,用于传播应取消操作的通知。

返回

Task<TUser>

表示异步操作的 , Task 包含与指定的 userId 匹配(如果存在)的用户。

实现

适用于