Created
March 11, 2014 15:45
-
-
Save Mark-Broadhurst/9488495 to your computer and use it in GitHub Desktop.
Nhibernate Thread Static CurrentSessionContext that supports multiple ISessionFactory's
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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