views:

106

answers:

2

Hi!

I'm looking for an NHibernate criterion which does not add a restriction to a criteria. The reason for this is that I have a method which converts some input parameters into a criterion which is added to a criteria. There is a constellation of the input parameters where no restriction needs to by applied. Therefore I want to return some kind of dummy criterion.

Is there something like that in NHibernate?

Best Regards,
Oliver Hanappi

A: 

well you could do something like Restrictions.IsNotNull("id") if querying against an entity with 'id' being a primary key (and so can never be null). Anything that evaluates to no logical restriction can be used based on your requirements.

Jaguar
A: 

I do not understand the problem .... If no restriction is to be applied for some input parameters, then just add no criterion to the criteria instance for those parameters ?

Frederik Gheysels