I currently have a C# MVC 2 web app using Fluent NHibernate (+ LINQ) in a Repository Pattern and am using Ninject to handle the MVC controller's constructor requirement that it be passed in the repository.
My Fluent NHibernate code is currently hooked into an IHttpModule, so the session can be opened and closed with the web request.
This works great until I try to hook my domain model into a console app.
First, I decided to move my database logic into my domain model. I'm guessing this is bad behavior but I am here asking for help on code design, so please feel free to make suggestions. I wanted to do this because I want to write a console app + web app on this domain model without caring where or how the data is stored. Perhaps I should have a separate "Infrastructure" project that uses the domain model to do a particular implementation?
Getting back to the question ... I run into a problem where it seems Fluent NHibernate's GetCurrentSession() assumes you're using the web - it crashes and I get a traceback to some NH code mentioning a WebSession.
For reference sake, the code is here: https://github.com/cthielen/RightsManagement .
My apologies for not being too specific; I'm looking for code design advice to best handle FNH + Linq in a repository pattern that works well both with the Web and a console app -- and separately asking if my database connection (i.e. NH logic) should be in the domain project or not.