NHibernate cells - they are turned into SQL

I'm a little new to NHibernate, and I accept code written by another developer. I want to learn how NHibernate converts lambda criteria to SQL.

I know that in Linq to SQL, using Lambda expressions in queries means that all this turns into an expression tree, and then into SQL (where possible) by the Linq to SQL provider. This can be seen by running DataContext.Log = Console.Out.

But what about expressing NHibernate criteria where Linq to NHibernate is not used?

The following namespaces are imported ...

using NHibernate;
using NHibernate.Criterion;
using NHibernate.LambdaExtensions;

.. and the criteria code looks like this ...

    return Session.CreateCriteria<MyObjectType>()
        .Add<MyObjectType>(x => x.Id == id)
        .UniqueResult<MyObjectType>();

Will it be turned into an SQL statement, for example.

Select distinct * from table where id = [param]

... or the entire data array will be retrieved into memory by providing a list, and then apply the lambda expressions to the objects. eg.

return List<MyObject>.Where(x => x.id = id)  [or something similar].

I ', , NHibernate.LambdaExtensions SQL.

+3
1

HQL ( ), SQL .

.

+1

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


All Articles