Hello,
Beware that for version 3 (which is btw not official from the powers that
be), the API is different.
The aim of the new is to use IoC to a greater extent and hand-crafted code
to a lesser.
The code that selects database looks like this:
Component.For<ISessionManager>().Instance(new SessionManager(() => {
var factory =
Kernel.Resolve<ISessionFactory>(x.Instance.SessionFactoryKey);
var s = x.Instance.Interceptor.Do(y =>
factory.OpenSession(y)).OrDefault(factory.OpenSession());
s.FlushMode = _FlushMode;
return s;
}))
.Named(x.Instance.SessionFactoryKey + SessionManagerSuffix)
.LifeStyle.Singleton
So when you follow:
https://github.com/haf/Castle.Facilities.NHibernate/wiki/NHibernate-Facility
---Quick-Start
and implement the INHibernateInstaller, then you can choose the session
factory key.
When you then register your WcfSessionPerRequestCallContextInitializer, you
can choose what ISessionManager instance you depend on.
If you choose to go the manual way with Transactions, beware that you handle
the edge-cases well. Or even better; tell me what type of API you want to
see for release version 3.0, which doesn’t use AOP, but allows you to call a
‘transaction handler’ of some sort.
Cheers
From: [email protected]
[mailto:[email protected]] On Behalf Of Berke Sokhan
Sent: den 23 maj 2011 15:30
To: [email protected]
Cc: [email protected]
Subject: Re: NHibernateFacility and session-per-WCF-operation
Hello,
I am trying to achive the same thing with new Castle.Facilites.NHibernate
using one of the Richard's sources at his blog post article:
http://candland.net/blog/2009/10/27/nhibernate-session-per-request-using-cas
tles-wcffacility/
(I didnt choose to use Richard's method because it needs to decorate service
classes with [Transaction] attribute, which I would not prefer.)
The problem is new ISessionManager.Open doesnt take a string but instead
SessionManager's ctor takes a Func<ISession>, so the highlighted section in
the following does not work:
public class WcfSessionPerRequestCallContextInitializer :
ICallContextInitializer
{
private readonly ISessionManager sessionManager;
private readonly string[] dbAliases;
public WcfSessionPerRequestCallContextInitializer(ISessionManager
sessionManager, string[] dbAliases)
{
this.sessionManager = sessionManager;
this.dbAliases = dbAliases;
}
public object BeforeInvoke(InstanceContext instanceContext,
IClientChannel channel, Message message)
{
var extension = new NHibernateContextExtension();
foreach (var dbAlias in dbAliases)
{
extension.Sessions.Add(sessionManager.OpenSession(dbAlias));
}
instanceContext.Extensions.Add(extension);
return extension;
}
public void AfterInvoke(object correlationState)
{
if (correlationState != null)
{
((IDisposable)correlationState).Dispose();
}
}
}
- Can you give some pointers on how to enable per WCF operation session with
new Castle.Facilities.NHibernate?
- And also I use WcfIntegration to host services, do I have an option to use
WcfIntegration to solve this issue with a different implementation?
Thanks,
Berke Sökhan.
2010/8/17 Richard Dingwall <[email protected]>
On Aug 12, 9:17 pm, Adam Toseland <[email protected]> wrote:
> Hi Rich,
>
> I ended up implementing a solution for this based on this post.
>
> http://realfiction.net/go/133
> Cheers
> Adam,
Thanks, I started with your implementation but found a way that didn't
require any extra code:
http://richarddingwall.name/2010/08/17/one-nhibernate-session-per-wcf-operat
ion-the-easy-way/
Rich
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected]
<mailto:castle-project-users%[email protected]> .
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.
--
Berke SOKHAN.
http://twitter.com/berkesokhan
http://blog.berkesokhan.com
http://www.birliktegelistir.com/editors.aspx
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.