nhibernate webforms with class library
Posted
by frosty
on Stack Overflow
See other posts from Stack Overflow
or by frosty
Published on 2010-04-05T11:48:29Z
Indexed on
2010/04/05
11:53 UTC
Read the original article
Hit count: 313
nhibernate
|c#
very new to nhibernate. I'm a little confused on where features should live.
I have the following solution
1) MyProject.Web ( web forms application)
2) MyProject.Domain( class lib) - nhibernate.config - product.hbm.xml
So is it correct I should put the following method in a IHttpModule? ( i can't use a global asax as it's use by the CMS i'm running )
Where should the connectionString live?
HTTPModule in web forms application
private static ISessionFactory CreateSessionFactory()
{
var cfg = new Configuration().Configure(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "nhibernate.config"));
cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionStringName, System.Environment.MachineName);
NHibernateProfiler.Initialize();
return cfg.BuildSessionFactory();
}
nhibernate.config
<?xml version="1.0" encoding="utf-8" ?>
NHibernate.Dialect.MsSql2005Dialect NHibernate.Connection.DriverConnectionProvider NHibernate.Driver.SqlClientDriver 16 web NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle
enter code here
© Stack Overflow or respective owner