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
However, the following query does not work and gives error as highlighted in the stack trace below. I wanted to understand how we can optimally join the list navigation property with a third-property in a single query using EF core. Ideally we would have had the foreign key relationship between the wheel and the part - but for our use case we cannot have that in this scenario.
Include stack traces
Include the full exception message and stack trace for any exception you encounter.
---> System.InvalidOperationException: The LINQ expression 'DbSet<Vehicle>()
.Where(vehicle => vehicle.Id == __id_0)
.GroupJoin(
inner: __p_2,
outerKeySelector: vehicle => vehicle.Id,
innerKeySelector: wheelsWithPart => wheelsWithPart.VehicleId,
resultSelector: (vehicle, wheelsWithPart) => new {
Vehicle = vehicle,
WheelsWithPart = wheelsWithPart
}
)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.Expand(Expression query)
at Microsoft.EntityFrameworkCore.Query.QueryTranslationPreprocessor.Process(Expression query)
at Microsoft.EntityFrameworkCore.Query.RelationalQueryTranslationPreprocessor.Process(Expression query)
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.Query.Internal.EntityQueryable`1.GetAsyncEnumerator(CancellationToken cancellationToken)
at System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable`1.GetAsyncEnumerator()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
Include provider and version information
EF Core version: 5.0
Database provider: Microsoft.Data.SqlClient
Target framework: .NET 5.0
Operating system: Windows 10
IDE: Visual Studio Enterprise 2019 16.9.7
The text was updated successfully, but these errors were encountered:
We had to use AsSingleQuery as we are using EF core 5.0 yet and I saw that EF core 6.0 has the changes for supporting split queries for non-navigation collections. We will try upgrading to EF core 6.0 at some time.
Ask a question
Include your code
I have 3 entity classes (automatically derived from SQL table schema) as follows:
Further the query command is written as follows: The intention of the query is to include details of wheel
However, the following query does not work and gives error as highlighted in the stack trace below. I wanted to understand how we can optimally join the list navigation property with a third-property in a single query using EF core. Ideally we would have had the foreign key relationship between the wheel and the part - but for our use case we cannot have that in this scenario.
Include stack traces
Include the full exception message and stack trace for any exception you encounter.
Include provider and version information
EF Core version: 5.0
Database provider: Microsoft.Data.SqlClient
Target framework: .NET 5.0
Operating system: Windows 10
IDE: Visual Studio Enterprise 2019 16.9.7
The text was updated successfully, but these errors were encountered: