NHIbernate: difference between Restriction.In and Restriction.InG

When creating criteria in NHibernate, I can use

Restriction.In () or
Restriction.InG ()

What is the difference between the two?

+4
source share
2 answers

InG - the general equivalent of In (for collections)

The signature of the methods is as follows (only ICollection In overload is displayed):

In(string propertyName, ICollection values) 

vs.

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

Looking at the source code of NHibernate (trunk), it seems that they are copying the collection into an array of objects and will use this in the future, so I don't think there is a difference in performance between them.

I personally just use In in most cases - it's easier to read.

+11
source

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

0
source

Source: https://habr.com/ru/post/1276461/


All Articles