Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: Add Support for DateTimeOffset.Add* functions #8590

Closed
John0King opened this issue May 25, 2017 · 4 comments
Closed

Query: Add Support for DateTimeOffset.Add* functions #8590

John0King opened this issue May 25, 2017 · 4 comments
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. good first issue This issue should be relatively straightforward to fix. help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. type-enhancement
Milestone

Comments

@John0King
Copy link

DateTime.AddMinutes() and DateTimeOffset.AddMinutes() dosn't translate to sql

Steps to reproduce

//model
    public class Show
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public DateTime StartTime { get; set; }
        public TimeSpan DurationAsTimeSpan { get; set; }
        public int DurationAsInt32 { get; set; }  //minutes , same as DurationAsTimeSpan , juset for test
    }

//linq 
var y = _db.Shows.Where(r => r.StartTime.AddMinutes(r.DurationAsInt32) > dt ).ToList();

//and this is the out sql 
/*
SELECT [r].[Id], [r].[DurationAsInt32], [r].[DurationAsTimeSpan], [r].[StartTime], [r].[Title]
FROM [Shows] AS [r]
*/

Further technical details

EF Core version: 1.1.2
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: win7-x64
IDE: Visual Studio 2017

@pmiddleton
Copy link
Contributor

DateAdd support has been added to the 2.0 branch for DateTime, but not for DateTimeOffset.

@sdanyliv
Copy link

Maybe EF should have simple way to support custom functions also, for example as an extensions? Real DB projects has many functions that speedup queries instead of calculating almost everyting on the client side.

@John0King
Copy link
Author

@pmiddleton Why it doesn't support DateTimeOffset , left or by design?

@pmiddleton
Copy link
Contributor

@John0King - my best guess is because its low priority so no one has it on their todo list.

@ajcvickers ajcvickers added the help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. label May 26, 2017
@ajcvickers ajcvickers added this to the Backlog milestone May 26, 2017
pmiddleton added a commit to pmiddleton/EntityFramework that referenced this issue Jun 11, 2017
pmiddleton added a commit to pmiddleton/EntityFramework that referenced this issue Jun 14, 2017
pmiddleton added a commit to pmiddleton/EntityFramework that referenced this issue Jun 14, 2017
@smitpatel smitpatel modified the milestones: 2.0.0, Backlog Jun 21, 2017
@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jun 21, 2017
@smitpatel smitpatel changed the title Dose EF Core Support DateAdd ? Query: Add Support for DateTimeOffset.Add* functions Jun 21, 2017
@bricelam bricelam added good first issue This issue should be relatively straightforward to fix. and removed good first issue This issue should be relatively straightforward to fix. labels May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. good first issue This issue should be relatively straightforward to fix. help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. type-enhancement
Projects
None yet
Development

No branches or pull requests

6 participants