Save entities to the database
Clearly we have saved entities to the database in many of the previous recipes, but it's time to dig a bit deeper into how that actually works. This recipe will explore different ways of saving and what happens behind the scenes.
Getting ready
- Create a new Windows forms project named
SessionRecipes
, in Visual Studio. - Add a reference to
NHibernate
using NuGet Packet Manager Console:Install-Package NHibernate -project SessionRecipes
- Also add a reference to
NH4CookbookHelpers
:Install-Package NH4CookbookHelpers -project SessionRecipes
- Remove the class
Form1.cs
from the project. - Add
using NH4CookbookHelpers;
to the top ofProgram.cs
. - Edit
Program.cs
so that the last line inMain
reads:Application.Run(new WindowsFormsRunner()); ...
Get NHibernate 4.x Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.