This is a migrated thread and some comments may be shown as answers.

Events or overrides

8 Answers 65 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
CodeMonkey
Top achievements
Rank 2
CodeMonkey asked on 30 Oct 2009, 08:52 PM
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

8 Answers, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 30 Oct 2009, 10:51 PM
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.
0
CodeMonkey
Top achievements
Rank 2
answered on 31 Oct 2009, 10:18 PM
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.
0
IT-Als
Top achievements
Rank 1
answered on 01 Nov 2009, 08:55 AM
Hello CodeMonkey,

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

Regards

Henrik
0
CodeMonkey
Top achievements
Rank 2
answered on 02 Nov 2009, 10:09 PM
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.
0
IT-Als
Top achievements
Rank 1
answered on 03 Nov 2009, 04:23 PM
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....
  }

}
0
Jon
Top achievements
Rank 1
answered on 18 Sep 2013, 10:20 PM
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.
0
Damyan Bogoev
Telerik team
answered on 19 Sep 2013, 12:21 PM
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.
0
Jon
Top achievements
Rank 1
answered on 20 Sep 2013, 08:08 PM
Thank you Damyan, that was very helpful. I've modified my application and it's working as expected.
Tags
General Discussions
Asked by
CodeMonkey
Top achievements
Rank 2
Answers by
Jan Blessenohl
Telerik team
CodeMonkey
Top achievements
Rank 2
IT-Als
Top achievements
Rank 1
Jon
Top achievements
Rank 1
Damyan Bogoev
Telerik team
Share this question
or