views:

64

answers:

1

How should I manage my session? I've seen some examples where the session is created in the constructor of the domainservice and destroyed in the dispose method, but this seems like a bad idea.

Would appreciate help here because I can't find any information.

+1  A: 

I don't know RIA Services very well but it's based on WCF so maybe you can use the pattern of one session for each Operation, like in web you can use the pattern Session per Request ?

http://www.google.ca/search?hl=en&safe=off&q=WCF+Nhibernate+operation+context&aq=f&aqi=&aql=&oq=&gs_rfai=

and the first response give some code : http://realfiction.net/go/133

The next version of NHibernate, the integration of WCF should be built-in, here'sthe source code from the trunk : https://nhibernate.svn.sourceforge.net/svnroot/nhibernate/trunk/nhibernate/src/NHibernate/Context/WcfOperationSessionContext.cs

Matthieu
Thanks for your response Matthieu. Thats seems like a good solution and I actually stumbled up on that too. However, I'm not sure if it's possible to use in RIA Services, so I'll guess I have to make some experimentations.
JH
Hmm, your able to change the InstanceContextMode in WCF but that doesn't seem to be possible in WFC Ria Services? I tried to change it but for me it seems that it uses PerSession no mather what I do.
JH
After further investigations I have noticed that RIA Services in fact uses PerCall by default, so maybe I'm closer to an solution than I thought.
JH