One of the current EF Core query translation defects is the lack of documentation of what is supported. To make the things harder, database providers are allowed to add translations to some CLR properties/methods they decide to, so even some LINQ query translates for one database provider, it could fail for another.
In this particular case, the unsupported member is
TimeOfDay. SqlServer provider supports it, but Npgsql doesn't. At least Npgsql has provided documentation for supported translations which shows that
TimeOfDay is missing (not supported).
From the other side, Npgsql supports
DateTime substract operator (but SqlServer doesn't), so one way to resolve the issue for Npgsql is to calculate
TimeOfDay by subtracting date portion from the datetime value
.ThenBy(c => c.Date - c.Date.Date)
Another way which would achieve the goal for this particular case (and should work with any provider) is to simply use the datetime value
.ThenBy(c => c.Date)
ThenBy is effect only for equal values in
OrderBy. Since you are first ordering by date part (w/o time), then for equal dates you could simply order by datetime, which would have the same effect as the time of day.
- EF Core 3, OrderByDescending and ThenBy rerurn error could not be translated
- Linq expression could not be translated Error Entity Framework Core 3
- EF core Linq groupby and having sum count - could not be translated and will be evaluated locally
- LINQ expression error could not be translated
- The LINQ expression could not be translated - Entity Framework Core
- EF Core Linq expression could not be translated
- EF Core ToDictionary throw expression could not be translated
- Entity Framework Core 3.1 - Linq - Could not be translated. Either rewrite the query in a form that can be translated
- EF Core: The LINQ expression could not be translated - Net Core 3.1
- EF Core 3.1 - The LINQ expression could not be translated (left joins with group by)
- C# IQueryable - TakeLast(__p_0)' could not be translated Error
- C# Linq error 'DbSet() .GroupJoin( inner: DbSet(), outerKeySelector: ' could not be translated
- The LINQ expression could not be translated - Error with Nullable Id field
- Entity framework core 2.1: could not be translated and will be evaluated locally
- What could cause a "This may indicate either a bug or a limitation in EF Core." error in a linq expression .net core 3.0?
- EF Core (LINQ) - The Query expression could not be Translated
- The LINQ expression could not be translated using Shadow Properties in MVC Core
- Could not find an implementation of the query pattern for source type 'System.Data.Entity.DbSet'
- The LINQ expression could not be translated and will be evaluated locally
- The LINQ expression could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation EF Core 3.1
- Enumerating IEnumerable in EF6 in debugger issues "Children could not be evaluated" error
- OrderByDescending with Skip and Take in LINQ shows error
- Method cannot be translated into a store expression syntax error
- LINQ Source Code Available
- The LINQ expression could not be translated
- .NET 4 Code Contracts: "requires unproven: source != null"
- Could not find an implementation of the query pattern Error
- The LINQ expression could not be translated. Eiither rewrite the query in a form that can be translated
- Avoid extra loop and could not find implementation of query pattern for source type int Select not found
- Entity Framework Core 3.1.1 Where query could not be translated. Either rewrite the query in a form that can be translated,
- Orderby() not ordering numbers correctly c#
- JSON Deserialization in C# comparison
- Change one field in an array using linq
- LINQ statment looks unreasonable to me: what's my error?
- Linq group by and order by sum
- Grouping Results in LINQ
- How can I reuse my explicit column selection?
- Add node and childnodes to XML File
- Take() Throws Not Implemented Exception Entity Framework 6 with MySQL
- How to aggregate the value from DISTINCT row using LINQ
- How to factorize a Linq request with multiple includes?
- How to use union between two different object in linq
- C# linq query with where subquery for each property
- Sorting dates already CHAR
- C#: How to manipulate List<String> using LINQ or LAMBDA expression
- Help With Generic LINQ OrderBy Lambda Expression
- linq query for common associations
- Remove results from a linq query depending on query text
- 'The LINQ expression node type 'Invoke' is not supported in LINQ to Entities' when lambda is passed as a parameter, but not when used directly
- How to get first character occurrence in text their keeping original order?