DateTime Range

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I have the following Linq query:

IQueryable<Article> articles = (from a in database.Articles
where a.IsPublished
== true
orderby a.UpdatedAt
descending).AsQueryable();

How can I get the articles which UpdatedAt is in a range of StartDate
to EndDate?

Thanks,
Miguel
 
Hello,

I have the following Linq query:

      IQueryable<Article> articles = (from a in database.Articles
                                                   where a.IsPublished
== true
                                                   orderby a.UpdatedAt
descending).AsQueryable();

How can I get the articles which UpdatedAt is in a range of StartDate
to EndDate?

Normally you can use operators >= and <= with DateTime objects, so
"where a.UpdatedAt >= StartDate && a.UpdatedAt <= EndDate". This
should work for LINQ to Objects, but I've no idea if EF maps this to
SQL correctly or not.
 
Back
Top