Handling my OA Context in a SVC world

Posted by Community Admin on 04-Aug-2018 21:01

Handling my OA Context in a SVC world

All Replies

Posted by Community Admin on 23-Feb-2012 00:00

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?

Posted by Community Admin on 28-Feb-2012 00:00

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,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 28-Feb-2012 00:00

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?

Posted by Community Admin on 02-Mar-2012 00:00

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,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 02-Mar-2012 00:00

Can you elaborate?  Do you mean the garbage collector is disposing it, or can I see this happening somewhere in the source?

I've always been told by the OA guys to explicitly call .Dispose() on the context, and also creating a context object is an expensive operation so keep those to a minimum.

Posted by Community Admin on 07-Mar-2012 00:00

Hello Steve,

 The disposing is handled in SitefinityHttpModule on End_Request event handler. 

Kind regards,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 07-Mar-2012 00:00

So then I should inherit from SitefinityHttpModule and override the Context_EndRequest to dispose of my custom OA context WITH the SF ones right?

Posted by Community Admin on 12-Mar-2012 00:00

Hello Steve,

 Yes, you could do that and it should be working fine.

All the best,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed