WaYdotNET - No public Twitter messages.
formats

Simple NHibernate Architecture

By Cassio Alves.

Introduction

I started using NHibernate at the end of last year and I am having a wonderful experience with it. The simple fact that I don’t have to maintain hundreds of procedures and data access abstraction classes to do basic CRUD operations is enough to justify the use of NHibernate (even though I used a custom code generation tool). Besides that, my code is amazingly clearer and simpler. I only need to worry about business and user interface logic now. All that pluming code has gone for good.

I had zero experience with ORM frameworks, so on the first couple of weeks using NHibernate I had a hard time with some issues, like using it with ASP.NET disconnected objects and abstracting NHibernate sessions from the domain layer. After putting in some effort I came out with a nice architecture that abstracts the NHibernate layer and allows me to work with an ASP.NET session.

Background

I am assuming you already have some familiarity with NHibernate. If you are new to NHibernate I encourage you to go to the website and download the reference documentation. I am using NHibernate 1.2 CR1 in this article.

The Architecture

The idea here is to keep my business objects unaware of an NHibernate session. So I created a different project for NHibernate stuff, called Shared.NHibernateDAL. It includes the session and transaction manager classes. I also created a common business object that serves as a base class for all my business entities. This class (BusinessObject) encapsulates the common methods and properties all entities that need to be persisted have, like Save(), Delete(), ID, etc.

Here’s a class diagram just to give an idea:

Screenshot - nh_classdiagram.jpg

The Implementation

The main classes on the NHibernateDAL project are the following:

  • NHibernateSessionManager – This is the class responsible for managing the NHibernate session. I’ve got this class from another NHibernate article on Code Project.
  • TransactionBlock – This is a class I created to manage transactions and abstract it from NHibernate. I will show an example of its use further on this article.
  • BusinessObject<T> – This is the base class for all the business entities I need to persist. It implements the basic CRUD methods.

 

LINK: http://www.codeproject.com/aspnet/NHibernateArchitecture.asp

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
formats

TDD using SqlCE and NHibernate

 

This article demonstrates how to use SQL Compact Edition to perform database unit testing of your Repository/DAO classes. More often than not, I cringe at the thought of performing database testing against the development database. It would be much easier and logical to perform database tests against a disposable datasource. This is where In-Memory and Embedded databases come into play.

 

Fonte:

http://www.codeproject.com/useritems/TDD_and_SqlCE.asp

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
formats

Test wlw e categorie

Published on April 17, 2007 by WaYdotNET in AiS, OpenOttica

vediamo se imposta bene le categorie o fa come gli pare :D

 

penso + la secondo cmq :P

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
formats

NHibernate Plugin for Visual Studio 2005

NHibernate Plugin for Visual Studio 2005

A graphical designer for Visual Studio 2005. The plugin provides drag and drop composition of an object model, from the Server Explorer. All required .hbm.xml hibernate mapping files are generated, along with the required entity class source files (C#).


link:

http://sourceforge.net/projects/nhibernateaddin/

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
formats

Test Tag BlogSpot

BlogSpot Tags:
 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn