我有以下类和方法:
public class UserManager<TUser, TKey> : IDisposable
where TUser : class, global::Microsoft.AspNet.Identity.IUser<TKey>
where TKey : global::System.IEquatable<TKey> {
public virtual Task<TUser> FindByIdAsync(TKey userId);
和:
private ApplicationUserManager _userManager;
public ApplicationUserManager UserManager
{
get
{
return _userManager ?? Request.GetOwinContext().GetUserManager<ApplicationUserManager>();
}
set
{
_userManager = value;
}
}
public class ApplicationUserManager : UserManager<ApplicationUser, int>
public class ApplicationUser : IdentityUser<int, CustomUserLogin, CustomUserRole, CustomUserClaim>
我想像这样调用这个方法:
var user = await UserManager.FindByIdAsync<ApplicationUser,int>(99);
它给我错误:
非泛型方法
'Microsoft.AspNet.Identity.UserManager.FindByIdAsync(int)' cannot be used with type arguments
最佳答案
如错误所述,FindByIdAsync
不接受类型参数。这些存在于声明类 UserManager<TUser, TKey>
var user = await UserManager.FindByIdAsync(99);
关于c# - The non-generic method cannot be used with type arguments in this context 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24574013/