I want to implement event management in my application and i wanna know what may be the best practice to achieve this goal. Event management in my case is to maintain a log of every insert/update/delete operation in my application.
-
1Edited your title. "Event management" is pretty vague.John Farrell– John Farrell2010-07-02 13:08:41 +00:00Commented Jul 2, 2010 at 13:08
-
1What detail level do you want? Every detail of every change, or just a generic "UserX edited ItemY at 2010-07-02T08:32:44"?GalacticCowboy– GalacticCowboy2010-07-02 13:34:31 +00:00Commented Jul 2, 2010 at 13:34
4 Answers
It sounds like you are refering to a database event, in that case i would use triggers on the db and not bother with any ASP.Net implementation.
1 Comment
What data access layer are you using? If you're using LINQ to SQL or Entity Framework you could hook into events in their contexts to track these operations. Or, if you have a service tier through which these operations all flow, you could raise events there.
Specifically, since you are using LINQ to SQL, then you can implement the partial methods InsertEntity, UpdateEntity, and DeleteEntity (where Entity is the name of each of your entities) on your strongly-typed DataContext. These hooks should be the exact place to perform your logging or other event processing.