Math operations in nHibernate Criteria Query
Posted
by Richard Tasker
on Stack Overflow
See other posts from Stack Overflow
or by Richard Tasker
Published on 2010-06-03T11:18:10Z
Indexed on
2010/06/03
11:24 UTC
Read the original article
Hit count: 515
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
© Stack Overflow or respective owner