Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2010 Beginners guide to fluent nHibernate

I need some tutorials on how to get started with nHibernate and Fluent nHibernate. I'm coming from an Entity Framework background (which seems easier to use). I've tried sites like http://www.summerofnhibernate.com/ to get a grasp on nHibernate itself, but it seems outdated.

I'd like to generate a mapping of my database tables (al la Entity Framework), and do simple CRUD using nHibernate. I'm also using ASP.NET MVC and Visual studio 2010. Thanks.

like image 222
Shawn Mclean Avatar asked Sep 19 '10 23:09

Shawn Mclean


People also ask

What is the difference between NHibernate and fluent NHibernate?

Fluent NHibernate offers an alternative to NHibernate's standard XML mapping files. Rather than writing XML documents, you write mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.

Is NHibernate better than Entity Framework?

EF Core can use a ROWVERSION/TIMESTAMP column on SQL Server, or any of a list of columns, when updating a record. NHibernate offers richer capabilities, besides SQL Server ROWVERSION/TIMESTAMP, it can also use database native mechanisms such as Oracle's ORA_ROWSCN, but also timestamp or version columns.


1 Answers

Although a few years old, Summer of NHibernate concepts are pretty much intact and that's what it teaches you best. If you're a patient learner, start there.

On the side of Fluent NHibernate, the best tutorial is still the official one. The minor gripe it has is that it assumes that you're coming from an NHibernate raw background, so it's not particularly great explaining how to configure NHibernate (i.e. installing binaries for it and any given database). Edit: See Update at the bottom.

  • ASP.NET MVC: Although there are good tutorials for using NHibernate with ASP.NET MVC, every resource focuses on ASP.NET MVC and/or simply getting them to work together, assuming you already know it. But if you insist...
  • NHibernate books: NHibernate 3.0 Cookbook.

    1. NHibernate: a knol by Fabio Maulo
    2. Your first NHibernate based application
    3. Fluent NHibernate wiki


A bit more advanced resources:
  • NHibernate Profiler
  • S#arp Architecture: Best practices for ASP.NET and NHibernate.
  • Hibernate (based on the original, java-based Hibernate, but the concepts are still the same).
  • HQL: The Hibernate Query Language (I go here a lot).
  • LINQ for NHibernate examples.
  • Ayende @ Rahien: if you're on the NHibernate boat, you want to read whatever this guy writes.
  • NHibernate vs Entity Framework 4.0 - I think it's an advanced article because you won't understand it fully until you dabble with NHibernate, and if you have no clue about ORMs yet, you'll waste 5 minutes of your life.

Update: NHibernate can now be easily configured using NuGet.

like image 121
rebelliard Avatar answered Sep 23 '22 00:09

rebelliard