Created
February 14, 2019 20:44
-
-
Save jennings/6ec263d3268eb2215a3b47cf721b328c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define NONEST | |
void Main() | |
{ | |
Database.SetInitializer<MyContext>(null); | |
using (var db = new MyContext()) | |
{ | |
var date = "20180315"; | |
var query = from row in db.Tabl1 | |
where SqlFunctions.DateDiff( | |
"dd", | |
row.TheDate, | |
date.Substring(0, 4) + "-" + date.Substring(5, 2) + "-" + date.Substring(7, 2) | |
) > 0 | |
select row; | |
query.ToString().Dump(); | |
} | |
} | |
public class Tabl1 | |
{ | |
public int Id { get; set; } | |
public DateTime TheDate { get; set; } | |
} | |
public class MyContext : DbContext | |
{ | |
public DbSet<Tabl1> Tabl1 { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
[Extent1].[Id] AS [Id], | |
[Extent1].[TheDate] AS [TheDate] | |
FROM [dbo].[Tabl1] AS [Extent1] | |
WHERE (DATEDIFF(dd, [Extent1].[TheDate], CASE WHEN (SUBSTRING(@p__linq__0, 0 + 1, 4) IS NULL) THEN N'' ELSE SUBSTRING(@p__linq__0, 0 + 1, 4) END + N'-' + CASE WHEN (SUBSTRING(@p__linq__1, 5 + 1, 2) IS NULL) THEN N'' ELSE SUBSTRING(@p__linq__1, 5 + 1, 2) END + N'-' + CASE WHEN (SUBSTRING(@p__linq__2, 7 + 1, 2) IS NULL) THEN N'' ELSE SUBSTRING(@p__linq__2, 7 + 1, 2) END)) > 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment