AspNetCore.Identity.MongoDB icon indicating copy to clipboard operation
AspNetCore.Identity.MongoDB copied to clipboard

UserManager.Users throws System.NotSupported

Open Mech0z opened this issue 9 years ago • 5 comments

Hi, I am trying to use the Users to get all registered users, maybe I am using the framework wrong, but my idea is

I have https://github.com/Mech0z/FoosballCore2 which is a foosball site, I then want a setup page that can be run there if there is no user with Administrator claim.

Is there a way to get all users and check how many have a certain role? Or should I just make my own repository that gets all users and make a count myself.

Mech0z avatar Dec 11 '16 11:12 Mech0z

@Mech0z thanks for reporting this. this is currently by design but doesn't have to be that way. AFAIK, MongoDB .NET Driver supports queryable. So, MongoUserStore<TUser> could implement IQueryableUserStore<TUser> and expose _usersCollection.AsQueryable() through Users property.

I am not entirely sure though which LINQ operations MongoDB supports. We may need to write tests.

@Mech0z do you want to help me out on getting this implemented?

tugberkugurlu avatar Jan 30 '17 21:01 tugberkugurlu

As a workaround, you can query MongoDB by yourself through your own way.

tugberkugurlu avatar Jan 30 '17 21:01 tugberkugurlu

@Mech0z ⬆️ any thoughts?

tugberkugurlu avatar Feb 16 '17 09:02 tugberkugurlu

Sorry I havent had time to look at it, But since you fixed https://github.com/tugberkugurlu/AspNetCore.Identity.MongoDB/releases/tag/1.0.0-rc3 I have just made a derived User repo that can fetch both single and all users.

If I get time I can try to look at making a pull request if I can make an implementation of it into your framework

Mech0z avatar Feb 16 '17 11:02 Mech0z

If someone wants to tell me what test(s) may need to be written... the property takes ~30 seconds to add... so it's just adding tests to proof what we can/cannot do.

dealproc avatar Jun 15 '18 16:06 dealproc