Events or overrides

9 posts, 0 answers
  1. CodeMonkey
    CodeMonkey avatar
    10 posts
    Member since:
    Oct 2009

    Posted 30 Oct 2009 Link to this post

    Hi

    Are there any events or overrides that coincide with the following conditions

    database connection opening
    database connection opened
    database connection closing
    database connection closed

    I've had a hunt about but as I am new to OA I may be missing the obvious places.

    Thanks
  2. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 30 Oct 2009 Link to this post

    Hello CodeMonkey,
    Those events are not available. Because we have our own connection pool this can happen all the time.

    What do you want to achieve?

    Best wishes,
    Jan Blessenohl
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. CodeMonkey
    CodeMonkey avatar
    10 posts
    Member since:
    Oct 2009

    Posted 31 Oct 2009 Link to this post

    What I am hoping to achieve is to call a stored proc (audit related) whenever a series of updates (update/insert/delete) happens.
    I know I could add this call as the first thing after I start a Transaction but I am looking for a central place.
  5. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 01 Nov 2009 Link to this post

    Hello CodeMonkey,

    Maybe you can use one of the life cycle events for that if this is specific to certain classes.

    Regards

    Henrik
  6. CodeMonkey
    CodeMonkey avatar
    10 posts
    Member since:
    Oct 2009

    Posted 02 Nov 2009 Link to this post

    So to do what I want I would need implement this for every object and implement the PreStore method.

    Should I actually modify the Telerik generated files or should I have another set of files and add the interface in that file i.e. take advantage of the partial classes?

    What I am trying to do is set CONTEXT_INFO in the SQL database which can then be picked up by my triggers to set audit information. I would need to do this via a stored procedure and I would preferably only wish to set it once; perhaps I will have to manage this directly in my Repository layer.
  7. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 03 Nov 2009 Link to this post

    Hi CodeMonkey,

    Yes, the PreStore could be a location to place it. However, as I also mentioned..it depends if this is for all classes for only a few, since it requires you to implement the feature for all.

    Some other thoughts:

    1. You could define a super class for all your persistent classes that implements the PreStore.. Do not know if this will work, never tried it.
    2. You could wrap the IObjectScope in your own class, replicating the Commit, Rollback and StartTransaction methods and when do the stuff needed before/after Commit (your implementation)
    Like this (pseudo):

    class MyObjectScope
    {
      private IObjectScope scope;

      public StartTransaction()
      {
         // Proxy the call to the real method
         scope.Transaction....
      }

      public CommitTransaction()
      {
         // Either do stuff here

         // Proxy the call to the real method
         scope.Transaction.Commit();

         // or here....
      }

      public RollbackTransaction()
      {
         // Proxy the call to the real method
         scope.Transaction....
      }

    }
  8. Jon
    Jon avatar
    21 posts
    Member since:
    Dec 2012

    Posted 18 Sep 2013 Link to this post

    I realize that this is an old post, but I am trying to do the same thing. CodeMonkey, just curious whether you are still around and whether you were successful in setting CONTEXT_INFO.
  9. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 19 Sep 2013 Link to this post

    Hello Jon,

    I have prepared a sample application which demonstrates how to use OpenAccess ORM and CONTEXT_INFO. Before running the application please execute the DDL script (Db.sql) located under the application project.

    Note that the application is using the new OpenAccessContext instead of IObjectScope approach.

    You could find my comments in-lined in the source code explaining different steps.

    Hope that helps.

    Regards,
    Damyan Bogoev
    Telerik
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
  10. Jon
    Jon avatar
    21 posts
    Member since:
    Dec 2012

    Posted 20 Sep 2013 Link to this post

    Thank you Damyan, that was very helpful. I've modified my application and it's working as expected.
Back to Top
DevCraft banner