Reputation: 1089
I have 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 mapping:
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 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 bigger or equal with today date.I want to compare only date value, without time, but I am getting following error:
could not resolve property: PlannedDate.Date of: DomainMenu
Is it possible to it using QueryOver in Fluent Nhibernate or not? Note: I am interested only in using this solution , I do not want different methods as I already know them, I just want to know if it's possible with QueryOver.
Thanks.
Upvotes: 4
Views: 890
Reputation: 1337
NHibernate doesn't know what to do with the Date property, it's .Net property and the QueryOver API can't handle it.
Have a look at this blog on how to extend queryover with custom methods and properties
Upvotes: 3