Skip to content

Instantly share code, notes, and snippets.

@jennings

jennings/app.cs

Created Feb 14, 2019
Embed
What would you like to do?
#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; }
}
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
You can’t perform that action at this time.