8
8
<para >
9
9
The Linq provider works as an extension of the <literal >ISession</literal >. It is defined in the
10
10
<literal >NHibernate.Linq</literal > namespace, so this namespace has to be imported for using the
11
- Linq provider. Of course, the LINQ namespace is still needed too.
11
+ Linq provider. Of course, the Linq namespace is still needed too.
12
12
</para >
13
13
<programlisting ><![CDATA[ using System.Linq;
14
14
using NHibernate.Linq;]]> </programlisting >
15
15
<para >
16
16
Note: NHibernate has another querying API which uses lambda, <link linkend =" queryqueryover" >QueryOver</link >.
17
- It should not be confused with a LINQ provider.
17
+ It should not be confused with a Linq provider.
18
18
</para >
19
19
20
20
<sect1 id =" querylinq-querystructure" >
@@ -545,9 +545,10 @@ IList<Cat> cats =
545
545
}
546
546
}]]> </programlisting >
547
547
<para >
548
- It is required that at least one of the parameters of the method call has its value originating
549
- from an entity. Otherwise, the Linq provider will try to evaluate the method call with .Net
550
- runtime.
548
+ The method call will always be translated to SQL if at least one of the parameters of the
549
+ method call has its value originating from an entity. Otherwise, the Linq provider will try to
550
+ evaluate the method call with .Net runtime instead. Since NHibernate 5.0, if this runtime
551
+ evaluation fails (throws an exception), then the method call will be translated to SQL too.
551
552
</para >
552
553
</sect2 >
553
554
@@ -565,7 +566,7 @@ IList<Cat> cats =
565
566
<para > </para >
566
567
<para >
567
568
As an example, here is how to add support for an <literal >AsNullable</literal > method which
568
- would allow to call aggregates which lay yield <literal >null</literal > without to explicitly
569
+ would allow to call aggregates which may yield <literal >null</literal > without to explicitly
569
570
cast to the nullable type of the aggregate.
570
571
</para >
571
572
<programlisting ><![CDATA[ public static class NullableExtensions
@@ -579,7 +580,7 @@ IList<Cat> cats =
579
580
}
580
581
}]]> </programlisting >
581
582
<para >
582
- Adding support in Linq to NHibernate for this custom method requires a generator. For this
583
+ Adding support in Linq to NHibernate for a custom method requires a generator. For this
583
584
<literal >AsNullable</literal > method, we need a method generator, declaring statically its
584
585
supported method.
585
586
</para >
@@ -612,8 +613,8 @@ IList<Cat> cats =
612
613
</para >
613
614
<para >
614
615
For adding <literal >AsNullableGenerator</literal > in Linq to NHibernate provider, a new
615
- generators registry should be used. Derive from the default one and merge it. (Static
616
- declaration of method support case.)
616
+ generators registry should be used. Derive from the default one and merge it. (Here we
617
+ have a static declaration of method support case.)
617
618
</para >
618
619
<programlisting ><![CDATA[ public class ExtendedLinqToHqlGeneratorsRegistry :
619
620
DefaultLinqToHqlGeneratorsRegistry
0 commit comments