More in this section

Forums / Developing with Sitefinity / Handling my OA Context in a SVC world

Handling my OA Context in a SVC world

8 posts, 0 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    23 Feb 2012
    Link to this post
    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?
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    28 Feb 2012
    Link to this post
    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
  3. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    28 Feb 2012
    Link to this post
    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?
  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    02 Mar 2012
    Link to this post
    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
  5. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    02 Mar 2012
    Link to this post
    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.
  6. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    07 Mar 2012
    Link to this post
    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
  7. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    07 Mar 2012
    Link to this post
    So then I should inherit from SitefinityHttpModule and override the Context_EndRequest to dispose of my custom OA context WITH the SF ones right?
  8. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    12 Mar 2012
    Link to this post
    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
8 posts, 0 answered