[net5.0] Sequence '[Microsoft.EntityFrameworkCore.Query.QueryRootExpression]' cannot be converted to SQL
See original GitHub issuelinq2db 3.1.6 linq2db.EntityFrameworkCore 5.0.2 Microsoft.EntityFrameworkCore 5.0.0 TargetFramework net5.0
var query = dbContext.SomeItems.Where(x => x.IsDeleted && x.Updated < dateTime).Take(20);
return dbContext.SomeItems
.Where(x => query
.Select(y => y.PrimaryKeyStringId)
.Contains(x.PrimaryKeyStringId)
)
.ToLinqToDB()
.DeleteAsync();
LinqToDB.Linq.LinqException : Sequence '[Microsoft.EntityFrameworkCore.Query.QueryRootExpression]' cannot be converted to SQL.
at LinqToDB.Linq.Builder.ExpressionBuilder.ConvertSequence(BuildInfo buildInfo, ParameterExpression param, Boolean throwExceptionIfCantConvert)
at LinqToDB.Linq.Builder.WhereBuilder.Convert(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo, ParameterExpression param)
at LinqToDB.Linq.Builder.MethodCallBuilder.Convert(ExpressionBuilder builder, BuildInfo buildInfo, ParameterExpression param)
at LinqToDB.Linq.Builder.ExpressionBuilder.ConvertSequence(BuildInfo buildInfo, ParameterExpression param, Boolean throwExceptionIfCantConvert)
at LinqToDB.Linq.Builder.TakeSkipBuilder.Convert(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo, ParameterExpression param)
at LinqToDB.Linq.Builder.MethodCallBuilder.Convert(ExpressionBuilder builder, BuildInfo buildInfo, ParameterExpression param)
at LinqToDB.Linq.Builder.ExpressionBuilder.ConvertSequence(BuildInfo buildInfo, ParameterExpression param, Boolean throwExceptionIfCantConvert)
at LinqToDB.Linq.Builder.ExpressionBuilder.ConvertExpressionTree(Expression expression)
at LinqToDB.Linq.Builder.ExpressionBuilder.OptimizeExpressionImpl(Expression expr, HashSet`1 currentParameters)
at LinqToDB.Linq.Builder.ExpressionBuilder.<>c__DisplayClass45_0.<OptimizeExpression>b__0(Expression e)
at LinqToDB.Expressions.Extensions.Transform(Expression expr, Func`2 func)
at LinqToDB.Linq.Builder.ExpressionBuilder.OptimizeExpression(Expression expression)
at LinqToDB.Linq.Builder.ExpressionBuilder.ConvertSelect(MethodCallExpression method)
at LinqToDB.Linq.Builder.ExpressionBuilder.OptimizeExpressionImpl(Expression expr, HashSet`1 currentParameters)
at LinqToDB.Linq.Builder.ExpressionBuilder.<>c__DisplayClass45_0.<OptimizeExpression>b__0(Expression e)
at LinqToDB.Expressions.Extensions.Transform(Expression expr, Func`2 func)
at LinqToDB.Expressions.Extensions.Transform2[T](IEnumerable`1 source, Func`2 func)
at LinqToDB.Expressions.Extensions.Transform(Expression expr, Func`2 func)
at LinqToDB.Expressions.Extensions.Transform(Expression expr, Func`2 func)
at LinqToDB.Expressions.Extensions.Transform(Expression expr, Func`2 func)
at LinqToDB.Linq.Builder.ExpressionBuilder.OptimizeExpression(Expression expression)
at LinqToDB.Linq.Builder.ExpressionBuilder.ConvertWhere(MethodCallExpression method)
at LinqToDB.Linq.Builder.ExpressionBuilder.OptimizeExpressionImpl(Expression expr, HashSet`1 currentParameters)
at LinqToDB.Linq.Builder.ExpressionBuilder.<>c__DisplayClass45_0.<OptimizeExpression>b__0(Expression e)
at LinqToDB.Expressions.Extensions.Transform(Expression expr, Func`2 func)
at LinqToDB.Expressions.Extensions.Transform2[T](IEnumerable`1 source, Func`2 func)
at LinqToDB.Expressions.Extensions.Transform(Expression expr, Func`2 func)
at LinqToDB.Linq.Builder.ExpressionBuilder.OptimizeExpression(Expression expression)
at LinqToDB.Linq.Builder.ExpressionBuilder.ConvertExpressionTree(Expression expression)
at LinqToDB.Linq.Builder.ExpressionBuilder..ctor(Query query, IDataContext dataContext, Expression expression, ParameterExpression[] compiledParameters)
at LinqToDB.Linq.Query`1.CreateQuery(IDataContext dataContext, Expression expr)
at LinqToDB.Linq.Query`1.GetQuery(IDataContext dataContext, Expression& expr)
at LinqToDB.Linq.ExpressionQuery`1.GetQuery(Expression& expression, Boolean cache)
at LinqToDB.Linq.ExpressionQuery`1.LinqToDB.Async.IQueryProviderAsync.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
at LinqToDB.LinqExtensions.DeleteAsync[T](IQueryable`1 source, CancellationToken token)
It was ok before upgrade to 5.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Linq to SQL cannot translate because ...
I have been trying to run a query where I want to group all the records by a specific property, then select the...
Read more >SQL Queries - EF Core
Entity Framework Core allows you to drop down to SQL queries when working with a relational database. SQL queries are useful if the...
Read more >Breaking changes in EF Core 5.0
Complete list of breaking changes introduced in Entity Framework Core 5.0.
Read more >Breaking changes included in EF Core 3.x
When expressions in any other part of the query can't be converted to either SQL or a parameter, an exception is thrown. Why....
Read more >.Net 6 Upgrade - Microsoft Q&A
Hi Team, We are updating the .Net Core 3.1 framework to .Net 6 then we are getting this error. System.TypeInitializationException: 'The type ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I see. Will check. Could you please try the following as a workaround:
thanks