Introduction
Since all the recipes in this chapter deal with querying, we have provided the necessary setup and data using the NH4CookbookHelpers
library. You can easily adapt the recipes to your own liking, but if you want to only test the queries, the supplied setup will work just fine.
Getting ready
Create a new
Windows Forms
project namedQueryRecipes
in Visual Studio.Add a reference to NHibernate using NuGet Packet Manager Console:
Install-Package NHibernate
Also, add a reference to NH4CookbookHelpers.
Remove the class
Form1.cs
from the project.Add
using NH4CookbookHelpers;
to the top ofProgram.cs
.Edit
Program.cs
so that the last line in Main reads:Application.Run(new WindowsFormsRunner());
If you use NH4CookbookHelpers
, you don't even have to have a database server available, since it uses an in-memory SQLite database by default. If you want to use something else, like a local SQL Server, you can specify a Configuration
instance to be used. Perhaps the most convenient way is to use a...