Skip to main content

Improve NHibernate QueryOver with extension methods

Improve NHibernate QueryOver with extension methods

In this tutorial, we will see how to centralize and produce more comprehensive code around NHibernate QueryOver by adding extensions methods.

Goals

At the end of this tutorial, we will have extension methods that centralize the definition of QueryOver manipulation.

In this way,

Advantages :

  • Ubiquitous or more comprehensive terms (with extension method name)
  • Where clause "Abstraction" / Composition / Reuse

Implementation

Domain Entities

Company

Contact

CompanyType

Domain Persistence

QueryOverContact

QueryOverCompany

Usages