How can we improve Entity Framework Core?

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.

37 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Diego VegaAdminDiego Vega (Program Manager, Microsoft Entity Framework) shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • markmark 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