tags:

views:

64

answers:

4

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.

+3  A: 

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.

Robert
I'd agree it's normally safer to have them at the DB level so that modifications outside the application are also caught and logged. Also assuming that you want to log the events to the database.
Andy Robinson
A: 

I agree with the answer that it can be done in the DB layer by using triggers. If you don't want to put it in the db layer, you can create an action filter for all of your actions (add/update/delete) - which writes to the log.

Johannes Setiabudi
+1  A: 

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.

John Bledsoe
yes im using LINQ to SQL
Fraz Sundal
+1  A: 

Use Change Data Capture http://www.mssqltips.com/tip.asp?tip=1474

Malcolm Frexner