1

With the help of Identity Dapper, I want to get a list of all users, but when accessing the Users property from the UserManager class, an exception is thrown.

Based on the commentary, I realized that the dupper does not support IQueryable. I also found out that all the logic for working with the database is located in the UserRepository class, which implements the IUserRepository

Question: how to expand the UserManager class, and add a method to get a list of all users from the database? I also need to inject the extended class in the ConfigureServices method in the Startup class.

//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();
                    }
                }
                ...
        }
murash
  • 211
  • 3
  • 14
  • 1
    Dapper does not "support" `IQueryable` because the SQL creation is on you; it has no facility to translate LINQ to SQL. `IQueryable`, however, is a LINQ construct, and it's really just an enumerable that LINQ can query. As such you can certainly return your Dapper results into an `IQueryable`. – Chris Pratt Mar 25 '19 at 16:38
  • Did you ever figure this out? I'm facing the same situation. – myahl Sep 26 '19 at 22:44

0 Answers0