Math operations in nHibernate Criteria Query
- by Richard Tasker
Dear All,
I am having troubles with a nHibernate query.
I have a db which stores vehicle info, and the user is able to search the db by make, model, type and production dates.
Make, model & type search is fine, works a treat, it is the productions dates I am having issues with. So here goes...
The dates are stored as ints (StartMonth, StartYear, FinishMonth, FinishYear), when the end-user selects a date it is passed to the query as an int eg 2010006 (2010 * 100 + 6).
below is part of the query I am using, FYI I am using Lambda Extensions.
if (_searchCriteria.ProductionStart > 0)
{
query.Add<Engine>(e => ((e.StartYear * 100) + e.StartMonth) >= _searchCriteria.ProductionStart);
}
if (_searchCriteria.ProductionEnd > 0)
{
query.Add<Engine>(e => ((e.FinishYear * 100) + e.FinishMonth) <= _searchCriteria.ProductionEnd);
}
But when the query runs I get the following message,
Could not determine member from ((e.StartYear * 100) + e.StartMonth)
Any help would be great,
Regards
Rich