Nhibernate - Update single field without loading entity?

HQL is the way to go.

Session.CreateQuery("update Product set Active = :active where id in (:ids)")
       .SetParameter("active", active)
       .SetParameterList("ids", listOfSelectedProductIds)
       .ExecuteUpdate();

Since NHibernate 5, you can use LINQ for updates/deletes, like this:

session.Query<Product>()
    .Where(p => listOfSelectedProductIds.Contains(p.Id))
    .Update(p => new { Active = active });

It will not load entities or increment versions.

https://nhibernate.info/doc/nhibernate-reference/querylinq.html#querylinq-modifying

Tags:

C#

Nhibernate