-
Notifications
You must be signed in to change notification settings - Fork 3.3k
AsSplitQuery not implemented on EF Core InMemory #22034
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
AsNoTracking actually has effect on InMemory provider. AsSplitQuery is plain wrong. Note if you are using only one provider in your code, (e.g. InMemory) then you won't even get method |
Better exception and message? NotImplementedException should generally not be exposed by any of our APIs... |
Yeah I got it, but I have a business layer that I need to test, and all the test are having exceptions because of this... Looks really complicated and inadequate to add conditional logic on a business layer related the providers (maybe this method can be implemented to do nothing on the memory provider because memory provider is something a lot of devs use to create unit tests) If you have any other suggestion to use this without the need to inform the business layer about the provider that we are using, that will be awesome! |
Can throw InvalidOperationException instead. More than that, we cannot identify across provider if you used method from other provider. Same error would happen if you used |
yeah but EF.Functions.Collate or EF.Functions.DateTimeFromDateParts are really specific and it is fine to throw an error on memory provider, but AsSplitQuery is a global query modifier method to have the same behavior on the queries that we have on EF Core 2, an it will be common scenario to try to test code that will have this method to run common queries... |
I think we should look at what we can do to make this better. Its conceptually similar to what we did to allow transactions to be a no-op when using the in-memory provider. |
@ajcvickers that would be awesome, I understand that in memory provider that method will do nothing, but will be great for the Unit Test context! Thanks! |
Decision from triage: no-op for the in-memory provider. |
@ajcvickers awesome! Thanks! |
Manually verified - Works for Relational - No-op for InMemory - Throws translation failure for Cosmos Resolves #22034
Manually verified - Works for Relational - No-op for InMemory - Throws translation failure for Cosmos Resolves #22034
Manually verified - Works for Relational - No-op for InMemory - Throws translation failure for Cosmos Resolves #22034
Queries using the new 'AsSplitQuery' fail when using Memory Provider
Error: System.NotImplementedException : Unhandled method 'AsSplitQuery'.
I understand that this will have no effect on the memory " query ", but maybe there is a way to at least do nothing but don't throw an exception. (Like the AsNoTracking method) on Memory Provider
Steps to reproduce
Run any query using In Memory Context (EF Core InMemory) that contains a ' AsSplitQuery' method call.
System.NotImplementedException : Unhandled method 'AsSplitQuery'.
ERROR:
System.NotImplementedException : Unhandled method 'AsSplitQuery'.
STACK:
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass12_0
1.<ExecuteAsync>b__0() at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func
1 compiler)at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync[TSource,TResult](MethodInfo operatorMethodInfo, IQueryable
1 source, Expression expression, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync[TSource,TResult](MethodInfo operatorMethodInfo, IQueryable
1 source, LambdaExpression expression, CancellationToken cancellationToken)Further technical details
EF Core version: 5.0.0-preview.7.20364.11
Database provider: Microsoft.EntityFrameworkCore.InMemory
Target framework: .NET Core 3.1
Operating system: Windows 10 / Ubuntu 20
IDE: Visual Studio 2019 16.3 / VS Code
The text was updated successfully, but these errors were encountered: