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-castles-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-operation-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].
> 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.