在Identity Dapper的帮助下,我想要获取所有用户的列表,但是当从UserManager类访问Users属性时,会引发异常。
基于评论,我意识到dupper不支持IQueryable。我还发现,与数据库一起使用的所有逻辑都位于UserRepository类中,该类实现了IUserRepository
问题::如何展开UserManager类,并添加方法以从数据库中获取所有用户的列表?我还需要在Startup类的ConfigureServices方法中注入扩展类。
//piece of code from Identity.Dapper.Stores
public class DapperUserStore<TUser, TKey, TUserRole, TRoleClaim, TUserClaim, TUserLogin, TRole> :
IUserStore<TUser>,
IUserLoginStore<TUser>,
IUserRoleStore<TUser>,
IUserClaimStore<TUser>,
IUserPasswordStore<TUser>,
IUserSecurityStampStore<TUser>,
IUserEmailStore<TUser>,
IUserLockoutStore<TUser>,
IUserPhoneNumberStore<TUser>,
IQueryableUserStore<TUser>,
IUserTwoFactorStore<TUser>,
IUserAuthenticationTokenStore<TUser>
where TUser : DapperIdentityUser<TKey, TUserClaim, TUserRole, TUserLogin>
where TKey : IEquatable<TKey>
where TUserRole : DapperIdentityUserRole<TKey>
where TRoleClaim : DapperIdentityRoleClaim<TKey>
where TUserClaim : DapperIdentityUserClaim<TKey>
where TUserLogin : DapperIdentityUserLogin<TKey>
where TRole : DapperIdentityRole<TKey, TUserRole, TRoleClaim>
{
...
public IQueryable<TUser> Users
{
get
{
//Impossible to implement IQueryable with Dapper
throw new NotImplementedException();
}
}
...
}