8

I'm looking for a decent codebase that demonstrates how to use nHibernate as the persistance layer in an asp.net mvc3 project.

The two key pieces of understanding that I am looking to develop are

  1. How to deal with ISession and ISessionFactory.
  2. How to implement the repository pattern without leaking any details of its nHibernate implemenation.

I'm aware of Sharp Architecture and reading through that now - Its interesting but I'm more keen on finding a straight-forward web app to pick apart than another framework to learn.

Thanks in advance.

Peter Kneale
  • 1,854
  • 5
  • 19
  • 31
  • Maybe this article can be of help: http://hackingon.net/post/NHibernate-Session-Per-Request-with-ASPNET-MVC.aspx . I read it and thought it was a pretty straight forward way of implementing NHibernate, which also isolates NHibernate to your MVC logic and therefor would be part of the rescue flow (and not end up with ASP.NET error if a dispose would throw an exception) – jishi Feb 06 '11 at 11:20

2 Answers2

3

I put together a project that offers an example of how to do this using nhibernate and asp.net mvc 2. The repository and nhibernate implementations will be almost the same. Probably the biggest change will be the ioc / dependency injection piece. Take a look. It should provide a solid starting point. Here is the URL.

http://gpsnerd.codeplex.com

Let me know if you have questions.

Bob

rcravens
  • 8,320
  • 2
  • 33
  • 26
1

Take a look at https://bitbucket.org/FunnelWeb/dev

FunnelWeb is a blog engine based on ASP.NET MVC and NHibernate. It is opensource and used by many bloggers/develoeprs

ITmeze
  • 1,902
  • 2
  • 21
  • 32