As I understand from all this readings of articles and blogs. In asp.net it is not correct to use:
Code:
[ThreadStatic] public static ISession mcurrentSession;
So in asp.net the following is equal:
I just create some IHttpModule and put an instance of my HibernateUtils (with: private ISession mcurrentSession) in
HttpContext.Current.Items with:
Code:
private void Context_BeginRequest(object sender, EventArgs e)
{
HibernateUtils hu = new HibernateUtils();
HttpContext.Current.Items.Add("HibernateUtils", hu);
}
private void Context_EndRequest(object sender, EventArgs e)
{
if (HttpContext.Current.Items["HibernateUtils"] != null)
{
HibernateUtils hu = (HibernateUtils)HttpContext.Current.Items["HibernateUtils"];
hu.CloseSession();
}
}
And the get the SESSION in all classses (Dao and similar classes) during Request with a simple call:
Quote:
HibernateUtils utils = (HibernateUtils)HttpContext.Current.Items["HibernateUtils"];
IQuery q = utils.CurrentSession.CreateSQLQuery(...);
Is all this thinking correct?
Lp
Sebastijan