score:3
Accepted answer
You can only use supported members in L2E queries, and Date
isn't one of those.
One workaround is to break your single L2E query into one L2E query followed by one LINQ to Objects query:
var q = from e in Context.Entities
select new
{
Id = e.Id,
DateTime = e.DateTime
};
var r = from e in q.AsEnumerable()
select new
{
Id = e.Id,
Date = e.DateTime.Date
};
Source: stackoverflow.com
Related Articles
- Entity Framework object limitations in aggregate LINQ query
- Entity Framework 6 Add nested child object in Parent object in LINQ Query
- Entity Framework object LINQ query Timeout issues
- Entity Framework LINQ query left join into new object instead of null
- Proper Linq Query for objects with many to many relation ship generated with code first entity framework
- Asp.Net Mvc Entity Framework Deserialized object Linq query null object
- Entity Framework Code Most First Efficient Linq Query
- Create nested object on Entity Framework Linq query
- Entity Framework Code First - The entity or complex type cannot be constructed in a LINQ to Entities query
- Entity framework linq query Include() multiple children entities
- How to avoid Query Plan re-compilation when using IEnumerable.Contains in Entity Framework LINQ queries?
- Should the order of LINQ query clauses affect Entity Framework performance?
- Entity Framework with LINQ aggregate to concatenate string?
- Entity Framework - Linq query with order by and group by
- Entity Framework 6 Compiled LINQ Query
- Convert string to int in an Entity Framework linq query and handling the parsing exception
- Deleting multiple records with Entity Framework using a single LINQ query
- Entity Framework LINQ Expression on object within object
- Simple conditional LINQ query in Entity Framework 4
- ThenInclude not working for an Entity Framework LINQ query
- Dynamic linq query expression tree for sql IN clause using Entity framework
- Retrieve single Entity Framework entities using a LINQ query or GetObjectKey?
- Entity Framework Linq Query to List - Error when using contains: Only primitive types, enumeration types and entity types are supported
- Entity Framework with Oracle using odp.net not taking parameters in linq query
- How can I view the Entity Framework LINQ query plan cache?
- Entity Framework Core LINQ query with multiple where clauses
- Queryable Linq Query Differences In Entity Framework
- Reusable linq select query in Entity Framework
- Entity Framework Core linq query returns InvalidCastException
- Internal access for entities in Entity Framework makes simple linq where query crash
- Distinct ComboBox Items
- Why does an IF Statement effect the outcome of my LINQ Statement?
- IndexOf with Linq, accepting lambda expression
- How do I find a collection of nodes in HtmlAgilityPack using linq to xml?
- How to declare global variable for linq query that produces a sequence of anonymous types
- WPF combobox binding not working.. It is not showing the exact value
- Linq to XML select ancestors up to 2 levels
- Updating DataGridView with Linq on DB Change
- Using int.parse(string) in linq search doesn't work
- Replacing foreach on a list with LINQ
- SQL code to join to, and sum data in, a table referenced by comma delimited keys
- Linq ordering both parent and child related entities
- From Sql to Linq-toSql
- Entity Framework execute query with not mapped properties. Expression tree
- Why is Dictionary.Add overwriting all items in my dictionary?
- Linq version of SQL "IN" statement
- How can I trim all elements in a list?
- Convert xml to class using Linq
- How does linq actually execute the code to retrieve data from the data source?
- How to soft-code a Linq/EF query