Fluent Nhibernate QueryOver fetch record by date only without time
I have the following object:
public class DomainMenu:EntityBase
{
public virtual DomainName DomainName { get; set; }
public virtual DateTime PlannedDate { get; set; }
public virtual DateTime CreationDate { get; set; }
public virtual string Notes { get; set; }
}
And the display:
public class DomainMenuMap : ClassMap<DomainMenu>
{
public DomainMenuMap()
{
Id(c => c.Id).GeneratedBy.Identity();
Map(c => c.PlannedDate);
Map(c => c.CreationDate);
Map(c => c.Notes);
References(c => c.DomainName);
}
}
I have the following method:
public IList<DomainMenu> GetDomainMenuesPlannedForNextDays(int domainId)
{
using (_unitOfWorkFactory.Create())
{
var todayDate = DateTime.Now.Date;
var list = _domainMenuRepository.QueryOver()
.Where(c=>c.PlannedDate.Date >= todayDate)
.Where(c => c.DomainName.Id == domainId)
.Future().ToList();
return list;
}
}
In this method, I want to get rows that have PlannedDate greater than or equal to today's date. I want to compare only date value without time, but I am getting the following error:
failed to resolve property: PlannedDate.Date of: DomainMenu
Is this possible using QueryOver in Fluent Nhibernate or not? Note. I am only interested in using this solution. I don't need different methods as I already know them, I just want to know if this is possible with QueryOver.
Thank.
+3
source to share