You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using EFCore with UseDbContext and returning an IQueryable that is not coming from EFCore (e.g. does not implement IAsyncEnumerable), then the query will fail with the error The source 'IQueryable' doesn't implement 'IAsyncEnumerable<Ocora.Services.Telematics.Core.Entities.Masterdata.Dtos.AssetDto>'. Only sources that implement 'IAsyncEnumerable' can be used for Entity Framework asynchronous operations.
I know that in general always the database IQueryable should be returned for performance reasons and possible filtering but in some cases this might not be possible and for debugging it can also be helpful to return a list instead of the IQueryable.
@michaelstaib I'm wondering if a type check like if (Source is IAsyncEnumerable<T> ae) is really a good idea in terms of performance because it would add that type check for every request. I think returning a list.AsQueryable() is the rare exception, isn't it? If so I would rather try to catch the exception and respond to it with 'queryable.ToList(). That's pretty slow in comparison to the if` but only kicks in when there is no Quyerable coming from EF.
The ToListMiddleware is in the EFCore package so we expect it to not work on anything else than EFCore. I think we can close this one. Since its actually not a bug.
Describe the bug
When using EFCore with UseDbContext and returning an IQueryable that is not coming from EFCore (e.g. does not implement IAsyncEnumerable), then the query will fail with the error
The source 'IQueryable' doesn't implement 'IAsyncEnumerable<Ocora.Services.Telematics.Core.Entities.Masterdata.Dtos.AssetDto>'. Only sources that implement 'IAsyncEnumerable' can be used for Entity Framework asynchronous operations.
I know that in general always the database IQueryable should be returned for performance reasons and possible filtering but in some cases this might not be possible and for debugging it can also be helpful to return a list instead of the IQueryable.
The error comes from here: https://github.com/ChilliCream/hotchocolate/blob/c1eb36cf3542572372847c5e38f4bc349bc22bfa/src/HotChocolate/Data/src/EntityFramework/ToListMiddleware.cs#L23-L25
I think this needs a check for IAsyncEnumerable similar to https://github.com/ChilliCream/hotchocolate/blob/c1eb36cf3542572372847c5e38f4bc349bc22bfa/src/HotChocolate/Data/src/Data/QueryableExecutable.cs#L44
Maybe this is even a bug as it's not using that extension method but the EFCore internal extension method cause of a missing/wrong using statement?!
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No exception as ToList is used instead of ToListAsync if IQueryable does not implement IAsyncEnumerable
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: