Skip to content

Instantly share code, notes, and snippets.

@Mark-Broadhurst
Created March 11, 2014 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mark-Broadhurst/9488495 to your computer and use it in GitHub Desktop.
Save Mark-Broadhurst/9488495 to your computer and use it in GitHub Desktop.
Nhibernate Thread Static CurrentSessionContext that supports multiple ISessionFactory's
using System;
using System.Collections;
using NHibernate.Context;
using NHibernate.Engine;
public class ThreadStaticMultiSession : MapBasedSessionContext
{
[ThreadStatic]
private static IDictionary sessionFactories;
public ThreadStaticMultiSession(ISessionFactoryImplementor factory)
: base(factory)
{
}
protected override IDictionary GetMap()
{
return sessionFactories;
}
protected override void SetMap(IDictionary value)
{
sessionFactories = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment