I would like to fetch all records from particular day, no matter what time is associated with those records. So far I have method like this:
public IQueryabl
It depends on the LINQ provider. I'm not sure if NHibernate LINQ provider supports the item.SomeDateProperty.Date == x
syntax and I'm doubtful it does. But, you can make your own extension method like so:
public static IQueryable FilterByDate(this IQueryable This, Expression> getProperty, DateTime date)
{
DateTime from = day.Date;
DateTime to = day.Date.AddDays(1);
return This.Where(x=>
Expression.And(
Expression.GreaterThan(getProperty, Expression.Variable(from)),
Expression.LessThan(getProperty, Expression.Variable(to)));
}
This is NOT going to build the way it is now - I was just trying to give you an idea of what to do.
You can then use it like so:
var result = repository.Table.FilterByDate(x=>x.MyDate, new DateTime(2012, 6,6));