开发者

Example of a simple ASP.NET MVC + NHibernate + Fluent with proper session handling?

开发者 https://www.devze.com 2023-01-15 07:52 出处:网络
I\'m new to all of these technologies. I would like to see a simple (not over the top) example of how you would set up a project with these technologies. The most important being the proper NHibernate

I'm new to all of these technologies. I would like to see a simple (not over the top) example of how you would set up a project with these technologies. The most important being the proper NHibernate session handling (using HttpContext). Or we can build off of what I already have.

I've seen several examples of one piece or another but nothing with all of these technologies mixed. I'm having a tough time tying them together.

Right now I have an NHibernateHelper class (<-- see the pastebin link) that someone provided me as an example. I've modified it slightl开发者_JAVA百科y. I think I need to do some stuff in my Global.asax.cs file but I'm not sure exactly what. I need to somehow initialize the NHibernateHelper by passing its constructor an Assembly... but what kind of Assembly? This is where I get really lost. What am I missing?


In your example, The Assembly parameter is the Assembly that contains all Mapping files (hbm.xml) or Mapping classes (fluent nhibernate).

I'do like to recommend you to read this Tutorial. This is how i usually do, create a new HttpModule that opens a new session once per request and binds it to the web context. At the end of the request the session is closed. This is another example of the same implementation, although the post is written in pt-BR, the code is in english.

0

精彩评论

暂无评论...
验证码 换一张
取 消