Handling my OA Context in a SVC world
I have a OA model pointing at a seperate DB, and I'm exposing it inside my SF instance with some WCF services.
Question though is how should I be maintain the OA Context? Are you guys creating a context per manager then disposing it on dispose...or is it a single context shared in memory somewhere...?
What's the best way to handle this?
Hello Steve,
Sitefinity's data model structure is very complex, but in general - for each GetManager call we create a new context that is disposed when the transactions are finished. In general, you have both ways - either a shared context or creating multiple contexts and disposing them after the transaction is completed. Your choice should depend on the specific case.
All the best,Ahha...ok so .SaveChanges does more than just call the contexts .SaveChanges then right?...so if thats the case and someone doesnt call savechanges on a manager, dont you have an orphaned context?
Hi Steve,
The context is always disposed when the request ends. So even if you don't call SaveChanges, on request end it will be disposed.
Greetings,Can you elaborate? Do you mean the garbage collector is disposing it, or can I see this happening somewhere in the source?
Hello Steve,
The disposing is handled in SitefinityHttpModule on End_Request event handler.
Kind regards,So then I should inherit from SitefinityHttpModule and override the Context_EndRequest to dispose of my custom OA context WITH the SF ones right?
Hello Steve,
Yes, you could do that and it should be working fine.
All the best,