Thursday, May 31, 2012

Ignore time portion of datetime in LINQ

Ignore time portion of datetime in LINQ

using System.Data.Entity


public class TestClass
{
   public void TestMethod()
   {
      ShellContext db = new ShellContext();
        DateTime today = DateTime.Now;



var query = (from q in db.People
        where EntityFunctions.TruncateTime(q.CreateDate) < today.Date
        select q).FirstOrDefault();
    }
}

No comments:

Post a Comment