Module using NHibernate to access external SQL Data

Topics: General, Writing modules
Sep 18, 2012 at 7:54 PM

I'd like to write a module that uses NHibernate to access an external SQL server.

I assume that this would work pretty easily - just need to make sure configuration namespace doesn't overwrite each other (easy enough I assume).

Any samples or modules out there that already does this?

Also will I still need to wrap the data access with:

using (new TransactionScope(TransactionScopeOption.Suppress))


Sep 18, 2012 at 8:18 PM

Yes, you will need to wrap your data access.

Sep 18, 2012 at 9:07 PM

I was looking at your OrchardPo - but that uses the existing SQL Connection - is there anything out there showing how to do this to an external SQL server?

I only ask because I've never used nHibernate and am taking on a larger learning curve than I'd like.


Sep 19, 2012 at 12:14 AM

Not that I know of.

Sep 19, 2012 at 9:52 PM

Finally got my class written. I built it after looking at your bertrandleroy's OrchardPo project (which uses the existing nHibernate connection to look at non content related data) and a project located at:

Which uses nHibernate in an ASP.NET page (used it to tie nhibernate to the session)

Then finally a little information from the below link in order to support multiple databases so that I can have both a dev and production database for the data.

If anyone has any questions or problems - let me know - it wasn't too bad - just a lot of reading.



Oct 4, 2012 at 9:24 AM

I'd love to read a blog post on that :)