What is the best way to transparently log changes to objects when using LINQ-to-SQL?

I've done some similar work on auditing changes -- which is the first step. My solution works by making my designer context abstract then deriving the real context from it and overriding SubmitChanges. It works in conjunction with a separate audit context and a helper class that can take an object and construct the audit object from it.It relies on attributes to give the necessary information on which class is the audit class for a particular object You can find more information on my blog at farm-fresh-code.blogspot.com It's too involved to repeat here.

I've done some similar work on auditing changes -- which is the first step. My solution works by making my designer context abstract then deriving the real context from it and overriding SubmitChanges. It works in conjunction with a separate audit context and a helper class that can take an object and construct the audit object from it.It relies on attributes to give the necessary information on which class is the audit class for a particular object.

You can find more information on my blog at farm-fresh-code.blogspot.com. It's too involved to repeat here.

Since L2S generates code for you, and you wish to alter the behaviour of the generated code I see two possibilities: You start using T4 templates to generate the code from the dbml file and alter the template to add your functionality. This method is described here You add the functionality to the generated (partial) datacontext class by writing a partial class yourself. In your partial class you can implement the create/update/delete methods (CreateCustomer, UpdateCustomer and DeleteCustomer) adding the functionality to store the change.

I hope these pointers can help you on your way.

For your fist question, you can get access to the objects awaiting changes with db.GetChangeSet() and to know which fields changed and what was the original value, you can use: ITable table = db. GetTable(entity.GetType()); ModifiedMemberInfo modifiedMembers = table. GetModifiedMembers(entity); object original = table.

GetOriginalEntityState(entity).

The best way is the hardest way - YouTube. The best way to transparently is (without quotes):.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions