tugberkugurlu / AspNetCore.Identity.MongoDB

MongoDB Data Store Adaptor for ASP.NET Core Identity
MIT License
230 stars 69 forks source link

UserManager.Users throws System.NotSupported #25

Open Mech0z opened 7 years ago

Mech0z commented 7 years ago

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.

tugberkugurlu commented 7 years ago

@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 commented 7 years ago

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

tugberkugurlu commented 7 years ago

@Mech0z ⬆️ any thoughts?

Mech0z commented 7 years ago

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

dealproc commented 6 years ago

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.