Paul and James, thank you very much for your responses. I have
tried these approaches, but with no luck. I'm noticing an issue that
is very interesting. Hopefully, something jumps out at you right
away. Here's an example of the code which presides in a class I call
'NHibernateHelper' (borrowed from NH in Action):
_cfg = new Configuration()
.SetNamingStrategy( naming strategy class here)
.SetProperty("current_session_context_class",
"thread_static");
// NOTE: At this point, the _cfg configuration object has 8 properties
including the current session context setting. The interesting part
comes next:
_sessionFactory = Fluently
.Configure(_cfg)
.Database
(
MsSqlConfiguration.MsSql2005
.ConnectionString(c =>
c.FromConnectionStringWithKey("conn"))
)
.Mappings
(
x => x.FluentMappings
.AddFromAssembly(...blah blah blah...)
)
.BuildSessionFactory();
After executing this piece of logic, the number of properties of the
_cfg configuration object has been reduced from 8 to 5 and the session
context setting is gone. Consequently, a piece of logic like this
fails since there is no session context:
try
{
using (ISession session =
NHibernateHelper.GetCurrentSession())
{
using (session.BeginTransaction())
{
CurrentSessionContext.Bind(session);
session.Save(person);
}
}
}
finally
{
CurrentSessionContext.Unbind
(NHibernateHelper.SessionFactory);
}
Any ideas? Thanks again for your help thus far!
On Mar 31, 6:21 am, James Gregory <
jagregory....@gmail.com> wrote:
> If you're using Fluently.Configure there's also a Raw method, which'll allow
> you to set any property that isn't already exposed.
>
>
>
> On Tue, Mar 31, 2009 at 12:17 PM, Paul Batum <
paul.ba...@gmail.com> wrote:
> > You set this on your NHibernate.Cfg.Configuration instance right?
>
> > You should be able to use the ExposeConfiguration method to get access to
> > the underlying Configuration instance and then set the session context
> > appropriately. Or alternatively you can build your Configuration instance as
> > you normally would including setting the session context, and then pass it
> > in as an argument to Fluently.Configure().
>
> > Paul Batum
>
> > On Mon, Mar 30, 2009 at 2:56 PM, Action Jackson <
crjac...@gmail.com>wrote:
>
> >> I apologize in advance if this question has been answered many times
> >> over. How can I specify the session context using the Fluent
> >> configuration? In other words, what is the Fluent translation of a
> >> traditional xml mapping like "<property
> >> name="current_session_context_class">thread_static</property>"?- Hide quoted text -
>
> - Show quoted text -