Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate (or other worth recommendation ORM), real life example?

I'd like to learn database applications in C# and I'm about to select some framework. I heard many recommendations of NHibernate, however I haven't decided yet.

Anyway, I'd like to know if there's any real-life example (with sources) of NHibernate in C#, to learn best practices etc.? I know all of them are probably covered in the docs, but working example helps a lot understanding the proper development pattern.

like image 256
migajek Avatar asked Feb 19 '11 23:02

migajek


People also ask

What is NHibernate used for?

NHibernate creates SQL for loading and storing objects based on an XML description of your entities and relationships. Designed specifically for use as a persistence layer for the . Net framework based on the Object-Relational Mapping Technique.

What is the difference between NHibernate and Entity Framework?

Entity Framework Core uses fluent (code-based) configuration and fluent or attribute-based mappings. Built-in conventions cannot be replaced or added to, at this moment. NHibernate has both XML and fluent configuration and mappings. It also offers attribute mappings through the NHibernate Attributes companion project.

Is NHibernate a framework?

NHibernate is a mature, open source object-relational mapper for the . NET framework. It's actively developed, fully featured and used in thousands of successful projects. Easily map regular C# or VB.NET object models designed in Visual Studio.


2 Answers

Check out Ayende@Rahien, there's a lot of blog entries on NHibernate there. Another good source is NHibernate Forge. To get you started this would be especially helpful: NHibernate Getting Started Guide. Finally here you can find a downloadable working example of a NHibernate project based on the Northwind database.

like image 163
Rian Schmits Avatar answered Nov 05 '22 06:11

Rian Schmits


The open source project S#arp Architecture is so far the best example I'm aware of for NHibernate:

  • S#arp Architecture

Even if it feels sometimes a little bit overdesigned, it follows best practices in implementing NHibernate in a multi-tier architecture.

I personally learned a lot about ORMs and good loosely coupled architecture going through the code of the project.

Another worthwhile article about NHibernate can be found on CodeProject:

  • NHibernate Best Practices
like image 25
Martin Buberl Avatar answered Nov 05 '22 07:11

Martin Buberl