Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store does not implement IQueryableUserStore<TUser> #5

Closed
critot opened this issue Sep 5, 2016 · 7 comments
Closed

Store does not implement IQueryableUserStore<TUser> #5

critot opened this issue Sep 5, 2016 · 7 comments
Assignees
Milestone

Comments

@critot
Copy link

critot commented Sep 5, 2016

Hi,
when I try to get all users stored in aspnetusers table:
var users = _userManager.Users;

I get this error

NotSupportedException: Store does not implement IQueryableUserStore.
get_Users

thank you

@dlmelendez
Copy link
Owner

This is due to the azure storage library not supporting linq queries. Any help on implementing the expression filter would be appreciated and kind of tricky to make it perform well.

@mstrong64
Copy link

There is an implementation of IQueryable at https://github.com/dtretyakov/WindowsAzure. Personally I would be inclined to get a list of users another way :)

@am11
Copy link

am11 commented Dec 25, 2016

I implemented a single sign-on service using this David's ElCamino table storage provider. One of the requirement was to get all Users loaded in memory at the application startup (singleton service).

Although bit of a performance hit, but I managed to simulate the "IQueryably get-all-users" behavior using this patch (on top of some old commit.. from Codeplex days):

-        IUserLoginStore<TUser> 
-        , IUserClaimStore<TUser> 
+        IUserLoginStore<TUser>, 
+        IQueryableUserStore<TUser>, IUserClaimStore<TUser> 
         , IUserRoleStore<TUser> 
         , IUserPasswordStore<TUser> 
         , IUserSecurityStampStore<TUser> 
@@ -223,6 +223,9 @@ await Task.WhenAll(_userTable.ExecuteAsync(TableOperation.Insert(item), cancella
             try 
             { 
                 await Task.WhenAll(tasks.ToArray()); 
+                var listified = _allUsers.ToList(); 
+                listified.Add(user); 
+                _allUsers = listified.AsQueryable(); 
                 return IdentityResult.Success; 
             } 

             catch (AggregateException aggex) 
@@ -832,7 +835,7 @@ public virtual Task<bool> IsInRoleAsync(TUser user, string roleName, Cancellatio
                 user.Roles.Remove(item);
                 TableOperation deleteOperation = TableOperation.Delete(item); 
-                await _userTable.ExecuteAsync(deleteOperation); 
+                await _userTable.ExecuteAsync(deleteOperation, cancellationToken); 
             } 
         } 
@@ -1126,6 +1129,10 @@ private TUser ChangeUserName(TUser user)
         public TContext Context { get; private set; } 
+        private IQueryable<TUser> _allUsers; 
+ 
+        public IQueryable<TUser> Users => _allUsers ??
+            (_allUsers = GetUsersAggregateAsync(new TableQuery()).Result.AsQueryable());

Each time a user is created, it updates the in-memory cache. The 'onion' architecture of ASP.NET Identity f/w eventually calls this _store.Users property, on each _userManager.Users call.

Note that it is an unwarranted territory as the framework internally re-instantiates the store object at different occasions, so it ends up calling GetUsersAggregateAsync( .. ) everytime for certain operations (I think for each GetClaimsAsync or such; found it during the debug session).

@dlmelendez
Copy link
Owner

There may be some hope to bring this back with the Storage team looking to bring back linq in netstandard2.0 release: Azure/azure-storage-net#491

@schey
Copy link

schey commented Nov 22, 2018

Just a quick question - is this related to the 'Users' not implemented error. I'm trying to get the user's telephone number by calling FindByEmail (which is used by resetpassword as well) and I'm getting an exception/null reference:

'this._userManager.Users' threw an exception of type 'System.NotImplementedException'
"The method or operation is not implemented."
"ElCamino.AspNetCore.Identity.AzureTable"
" at ElCamino.AspNetCore.Identity.AzureTable.UserStoreV28.get_Users()\r\n at Microsoft.AspNetCore.Identity.UserManager1.get_Users()"

(if there's another way, I'd greatly appreciate the advise)

Thanks much,

Eyal

@dlmelendez dlmelendez self-assigned this Sep 21, 2020
@dlmelendez dlmelendez added this to the v5 milestone Sep 21, 2020
@dlmelendez
Copy link
Owner

Putting this into v5 for basic query functionality.

dlmelendez added a commit that referenced this issue Sep 21, 2020
@dlmelendez
Copy link
Owner

fixed in v5-rc2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants