tugberkugurlu / AspNet.Identity.RavenDB

Fully asynchronous, new and sweet ASP.NET Identity implementation for RavenDB
MIT License
42 stars 28 forks source link

You can't get a sync query from async session #17

Closed SlyNet closed 10 years ago

SlyNet commented 10 years ago

When executing any query on UserManager.Users against RavenDB that is hosted as separate service System.NotSupportedException is thrown.

[NotSupportedException: You can't get a sync query from async session]
   Raven.Client.Document.Async.AsyncDocumentSession.Raven.Client.Linq.IDocumentQueryGenerator.Query(String indexName, Boolean isMapReduce) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\Async\AsyncDocumentSession.cs:618
   Raven.Client.Linq.RavenQueryProviderProcessor`1.GetLuceneQueryFor(Expression expression) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs:1439
   Raven.Client.Linq.RavenQueryProviderProcessor`1.Execute(Expression expression) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs:1477
   Raven.Client.Linq.RavenQueryInspector`1.GetEnumerator() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Linq\RavenQueryInspector.cs:105
tugberkugurlu commented 10 years ago

This is expected. You cannot perform syncronous query on IAsyncDocumentSession which this library only supports. You should perform all queries to RavenDB async anyway.

Use the provided async extension methods such as ToListAsync(), FirstOrDefaultAsync(), etc.

jstafford5380 commented 5 years ago

@tugberkugurlu This is a really old question but I think it still applies. Your answer is super vague and confusing, can you elaborate?

You say the library only supports sync query but that we should always perform async. How am I supposed to do this if there's only a sync query? You said to use ToListAsync() but I'm getting the same error. Could you provide a small example of what you mean? Thanks!