PacktLib: NHibernate 2 Beginner's Guide

NHibernate 2

Credits

About the Author

About the Reviewers

Preface

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!

Summary

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

Relationships

Normal Form

Putting it all together

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

Summary

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

Summary

Data Cartography

What is mapping?

Types of mapping

XML mapping

Mapping our types

Time for action – mapping basic types

Relationships

Time for action – mapping relationships

Fluent mapping

Summary

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

Summary

I'm a Logger

Why do we need to log?

Why log4net?

Getting started

Configuration

Time for action – adding some logging

NHibernate log messages

Appenders

Creating a logger

Time for action – adding some custom logging

Summary

Configuration

Looking back

The basics of configuration

Taking a look at the SQL

Abstracting the configuration

Time for action – moving our configuration

XML configuration

Summary

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

Summary

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

Summary

.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

Summary

It's a Generation Thing

Judging requirements

CodeSmith

nhib-gen

AjGenesis

Visual NHibernate

MyGeneration

Time for action – using MyGeneration

NGen NHibernate Code Generator

NHModeller

Microsoft T4 templates

T4 hbm2net

Summary

Odds and Ends

Unit of Work and Burrow

How does this relate to NHibernate?

Blog.Net blogging components

maxRequestLength

Converting CSS templates

Time for action – converting a CSS template

XML documentation & GhostDoc

Summary

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

Index