We have a form which allows users to specify criteria to query a database.
Our form builds “criterion” objects which are then used to build the nHibernate criteria.
Our current code to do this is:
public virtual ICriteria BuildCriteria(ICriteria criteria)
{
foreach (SheCriterion criterion in this.SheCriterions)
{
if (criterion.OperatorKey == "OR")
{
//// code required here to process ORs
}
criteria.Add(criterion.BuildCriterion());
}
return criteria;
}
Unfortunately, this is where I’m stuck – if we AND each criterion there is no problem but I’m having difficulties in working out how to add ORs – by the time we know that an OR is involved, the previous criterion has already been processed.
Can anyone help?
oris not that easy. Considera and b or cthere are 2 different possibilities(a and b) or canda and (b or c)so ifa = falseyou’ll get two different answers. You’ll have to build a tree of criterias and inUpdate: you’ll need a tree otherwise