Search for existing suggestions

Support for DateTime built-in operations in LINQ to Entities

Some customers want to write queries that include such expressions as "date1 - date2" or "datetime3 + timespan1 > datetime4". LINQ to Entities currently support some of date/time operations through the EntityFunctions.AddX and DiffX functions, but it doesn't support built-in operators with data/time types.

15 votes
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)

We’ll send you updates on this idea

AdminDiego Vega (Program Manager, Microsoft Entity Framework) shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

1 comment

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • mark commented  ·   ·  Flag as inappropriate

    Entity Framework should support using very common BCL features such as DateTime.Date in LINQ queries. Right now this requires the use of the special TruncateTime function.

    The problems are as follows:
    - This feels unnatural.
    - It also is a problem when migrating from LINQ to SQL which did support DateTime.Date.
    - It makes moving code across LINQ providers harder (e.g. move a piece of code from LINQ to objects to EF in order to remote it to the SQL Server)

    Other common features should be supported as well. For example DateTime.Year or TimeSpan stuff.

    Some are already supported such as Guid.NewGuid. That's good.

Feedback and Knowledge Base