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

DateTime.Now.TimeOfDay AND TimeSpan.Parse be client evaluated? #12187

Closed
wangpengxpy opened this issue May 31, 2018 · 5 comments
Closed

DateTime.Now.TimeOfDay AND TimeSpan.Parse be client evaluated? #12187

wangpengxpy opened this issue May 31, 2018 · 5 comments
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@wangpengxpy
Copy link

image

Steps to reproduce

    public class TestA
    {
        public int Id { get; set; }
        public string StrartEnd { get; set; }
        public string EndTime { get; set; }
        public TimeSpan TimeSpanStartEnd { get; set; }
        public TimeSpan TimeSpanEndTime { get; set; }
    }

    using (var context = new EFCoreDbContext())
    {
        var time = new TimeSpan(9, 00, 00);

        var test = context.TestAs.Where(d => d.TimeSpanStartEnd >= DateTime.Now.TimeOfDay && DateTime.Now.TimeOfDay <= d.TimeSpanStartEnd).ToList();

         OR

        var test1 = context.TestAs.Where(d => TimeSpan.Parse(d.StrartEnd) >= time && time <= TimeSpan.Parse(d.EndTime)).ToList();
     }

Further technical details

EF Core version: (2.0.1)
Database Provider: (Microsoft.EntityFrameworkCore.SqlServer)
Operating system:
IDE: (e.g. Visual Studio 2017 15.7.2)

@smitpatel
Copy link
Member

@wangpengxpy - What is incorrect in that? You are asking for whole entity so we are going to fetch all the columns in SELECT. The Where predicate could be client evaluated. Try 2.1 release which has translations for DateTime.Now.TimeOfDay.

@wangpengxpy
Copy link
Author

@smitpatel wow,It's my fault,tks。DateTime.Now.TimeOfDay can be translated in 2.1??

@wangpengxpy
Copy link
Author

@smitpatel TimeSpan.Parse also be client evaluated?

@wangpengxpy wangpengxpy changed the title sql translation incorrect DateTime.Now.TimeOfDay AND TimeSpan.Parse be client evaluated? May 31, 2018
@smitpatel
Copy link
Member

DateTime.Now.TimeOfDay is translated to server only on SQLite. But on SqlServer it would be still client eval.
TimeSpan.Parse is client eval and may not have easy translation to server.

@wangpengxpy
Copy link
Author

@smitpatel thanks for your reply,get it。

@ajcvickers ajcvickers added customer-reported closed-no-further-action The issue is closed and no further action is planned. labels Jun 4, 2018
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

3 participants