views:

81

answers:

1

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 slightly. 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?

A: 

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.

Guilherme Oenning
So if I'm using Fluent how do I know what the assembly is which contains all mapping classes? That seems to be 90% of my problem right now.
Joe Philllips
Well, I looked at your code and I suppose it's the assembly that contains the namespace 'ShoeParty.Mappings'.
Guilherme Oenning
Do I have to create that assembly somehow?
Joe Philllips
No, you should already have it, every Project that you create on Visual Studio generates an assembly. [Try this](http://jagregory.com/writings/fluent-nhibernate-auto-mapping-introduction/), by following this example you can even remove that Assembly parameter.
Guilherme Oenning
Where does `SessionHelper` come from? This isn't a complete solution which ends up causing the same headaches I already have
Joe Philllips