PacktLib: NHibernate 2 Beginner's Guide

NHibernate 2


About the Author

About the Reviewers


First Look

What is NHibernate?

Why would I use it?

Where do I get it?

Can I get help using NHibernate?

Database table

The XML mapping file (hbm.xml)

Plain Old CLR Object ( POCO )

Data access

Look how easy it is to use!


Database Layout and Design

Before you get started

Laying the foundation—table layouts

Time for action - creating an ordering system database

Table layouts

NHibernate assigned IDs


Normal Form

Putting it all together

Time for action - adding some tables to our Ordering system database


A Touch of Class

Start up our applications

Creating objects

Time for action - creating our first class

Public properties and private variables

Time for action - adding a few properties

Converting SQL database types to .NET types

Properties for Foreign Keys


Data Cartography

What is mapping?

Types of mapping

XML mapping

Mapping our types

Time for action - mapping basic types


Time for action - mapping relationships

Fluent mapping


The Session Procession

What is an NHibernate session?

Time for action - getting ready

What is a session factory?

Creating your first session

Why do we call .Commit()?

NHibernate session versus database session?

Time for action - creating a session and doing some CRUD

Sessions in ASP.NET


I'm a Logger

Why do we need to log?

Why log4net?

Getting started


Time for action - adding some logging

NHibernate log messages


Creating a logger

Time for action - adding some custom logging



Looking back

The basics of configuration

Taking a look at the SQL

Abstracting the configuration

Time for action - moving our configuration

XML configuration


Writing Queries

Using Data Access Objects

The basic Data Access Object

Time for action - creating our basic Data Access Object

Data Access Object methods

Time for action - adding some CRUD methods

Coding some GetX() methods

The FieldNames structure

Time for action - expanding our capabilities

The ICriteria object

Creating a GetAll() method

Paging and Sorting GetAll() methods

Filtering ICriteria

Time for action - replacing our inline code


Binding Data

Why should we use data binding?

Time for action - adding an ASP.NET project

Basic data binding techniques

Common data binding methods

A simple templated control

Creating a control instance

The control

The control

Time for action - adding our first data bound control

Direct data binding

One last control—the


.NET Security

Built-in controls

Time for action - adding a login to our page

Membership providers

Location security

Configuring our provider

Time for action - create a membership provider

User roles

Role providers

Provider configuration


It's a Generation Thing

Judging requirements




Visual NHibernate


Time for action - using MyGeneration

NGen NHibernate Code Generator


Microsoft T4 templates

T4 hbm2net


Odds and Ends

Unit of Work and Burrow

How does this relate to NHibernate?

Blog.Net blogging components


Converting CSS templates

Time for action - converting a CSS template

XML documentation & GhostDoc


Pop quiz - Answers

Pop quiz - Answers

Pop quiz - Answers

Pop quiz - Answers

Pop quiz - Answers

Pop quiz - Answers

Pop quiz - Answers

Pop quiz - Answers

Pop quiz - Answers

Pop quiz - Answers

Pop quiz - Answers