Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHIbernate: Difference between Restriction.In and Restriction.InG

Tags:

c#

orm

nhibernate

When creating a criteria in NHibernate I can use

Restriction.In() or
Restriction.InG()

What is the difference between them?

like image 606
lomaxx Avatar asked Dec 22 '22 14:12

lomaxx


1 Answers

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.

like image 111
Gareth Avatar answered Jan 13 '23 21:01

Gareth