This article is a mirror article of machine translation, please click here to jump to the original article.

View: 25695|Reply: 1

[Source] ef uses System.Data.Entity.DbFunctions.DiffDays to query the data for the current day and yesterday

[Copy link]
Posted on 11/8/2016 2:41:31 PM | | |
linq/ef framework Lambda expression where query for today's date
http://www.itsvse.com/thread-3093-1-1.html
(Source: Architect)


I tried many methods before



The result was incorrect

The specified type member "Date" is not supported. Only initial value settings, entity members, and entity navigation properties are supported.
I also used to convert strings, and I also got an error



Get it done


Let's take a look at the SQL statement generated by EF:

Inquiry today:

SELECT
    [GroupBy1]. [A1] AS [C1]
    FROM ( SELECT
        COUNT_BIG(1) AS [A1]
        FROM [dbo]. [ITSVSE] AS [Extent1]
        WHERE 0 = (DATEDIFF (day, [Extent1].[ CreateTime], SysDateTime()))
    )  AS [GroupBy1]

Query yesterday:

SELECT
    [GroupBy1]. [A1] AS [C1]
    FROM ( SELECT
        COUNT_BIG(1) AS [A1]
        FROM [dbo]. [ITSVSE] AS [Extent1]
        WHERE 1 = (DATEDIFF (day, [Extent1].[ CreateTime], SysDateTime()))
    )  AS [GroupBy1]






Previous:C# int to string with a comma for every three bits
Next:Creating mailbox file: File exists
 Landlord| Posted on 3/3/2017 12:08:00 PM |
Query yesterday's data
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com