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
Based on the Cosmos DB LINQ to SQL documentation, I had assumed string functions ToLower and ToUpper were supported during query translation. However the query throws an InvalidOperationException.
Steps to reproduce
To ensure this wasn't an issue with my work project's codebase, I cloned the Cosmos Sample from the Cosmos DB Provider's Get Started and was able to reproduce the issue.
SELECT*FROM c
WHERElower(c.Country) =lower('aMericA')
Actual
System.InvalidOperationThe LINQ expression 'DbSet<Order>().Where(o =>o.Country.ToLower()==__ToLower_0)' could not be translated.Eitherrewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.atMicrosoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.<VisitMethodCall>g__CheckTranslated|7_0(ShapedQueryExpressiontranslated,<>c__DisplayClass7_0&)at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpressionmethodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitorvisitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expressionnode)
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpressionmethodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitorvisitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expressionnode)
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpressionmethodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitorvisitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expressionnode)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expressionquery)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expressionquery,Booleanasync)at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabasedatabase,Expressionquery,IModelmodel,Booleanasync)at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass9_0`1.<Execute>b__0()atMicrosoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](ObjectcacheKey,Func`1compiler)at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](ObjectcacheKey,Func`1compiler)at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expressionquery)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expressionexpression)
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1source)
at Cosmos.ModelBuilding.Sample.<Run>d__0.MoveNext()inC:\Users\RavinduN\Downloads\Cosmos\ModelBuilding\Sample.cs:line 94
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Tasktask)
at Cosmos.Program.<Main>d__0.MoveNext()
Further technical details
EF Core version: 3.1.3
Database provider: Microsoft.EntityFrameworkCore.Cosmos
Target framework: .NET Core 3.1
Operating system: Windows 10 Enterprise 1909
IDE: Visual Studio 16.5.4
The text was updated successfully, but these errors were encountered:
Based on the Cosmos DB LINQ to SQL documentation, I had assumed string functions
ToLower
andToUpper
were supported during query translation. However the query throws anInvalidOperationException
.Steps to reproduce
To ensure this wasn't an issue with my work project's codebase, I cloned the Cosmos Sample from the Cosmos DB Provider's Get Started and was able to reproduce the issue.
Code used: https://github.com/dotnet/EntityFramework.Docs/tree/master/samples/core/Cosmos
Added a new property named Country to Order in Order.cs
Querying (After saving data)
Expected
Actual
Further technical details
EF Core version: 3.1.3
Database provider: Microsoft.EntityFrameworkCore.Cosmos
Target framework: .NET Core 3.1
Operating system: Windows 10 Enterprise 1909
IDE: Visual Studio 16.5.4
The text was updated successfully, but these errors were encountered: