Question

When creating a criteria in NHibernate I can use

Restriction.In() or
Restriction.InG()

What is the difference between them?

Was it helpful?

Solution

InG is the generic equivalent of In (for collections)

The signatures of the methods are as follows (only the ICollection In overload is shown):

In(string propertyName, ICollection values)

vs.

InG<T>(string propertyName, ICollection<T> values)

Looking at NHibernate's source code (trunk) it seems that they both copy the collection to an object array and use that going forward, so I don't think there is a performance difference between them.

I personally just use the In one most of the time - its easier to read.

OTHER TIPS

Restriction.In definately creates a subquery with whatever criteria you pass to the .In() method, but not sure what InG() does. never seen it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top