Introduction
Let's say I have this table:
Code:
Contracts
-------------
ID
CustomerID
DateLastPayment
Valid
And this is my object:
Code:
Contract
-------------
ID
CustomerID
LastPaymentDate
Valid
IsOverdue
As you can see, my object has one property more than my table:
IsOverdueThis property is calculated with this method:
Code:
public virtual bool IsOverdue
{
get
{
if (Valid && LastPaymentDate < System.DateTime.Now.AddDays(-31) )
{
return true;
}
else
{
return false;
}
}
}
QuestionI would like to know if it's possible to use Nhibernate to get all contract which are overdue. I mean, all contract for which IsOverdue == true.
Offcourse I know how to do this with SQL:
Code:
select * from Contracts
where Valid = 1 and ( DateLastPayment< dateadd(dd,-31, GETDATE() ) )
But is there a way to use the property IsOverdue on the object with Nhibernate?