c# – 在这种情况下,非泛型方法不能与类型参数一起使用是什么意
发布时间:2020-12-15 18:23:24 所属栏目:百科 来源:网络整理
导读:我有以下类和方法: public class UserManagerTUser,TKey : IDisposable where TUser : class,global::Microsoft.AspNet.Identity.IUserTKey where TKey : global::System.IEquatableTKey { public virtual TaskTUser FindByIdAsync(TKey userId); 和: priv
我有以下类和方法:
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); 它给了我错误: 非通用方法
解决方法
正如错误所述,FindByIdAsync不接受类型参数.这些存在于声明类UserManager< TUser,TKey>
var user = await UserManager.FindByIdAsync(99); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |