开发者

What is the best way to make many versions ((Or history)) of Table's rows

Hi everyone,

I'm trying to make my application support Logging but I'm very new at this approach.

  • I were going to add new tables to my database for each table that i want to support logging to it and then deal wit that by my DAL "EF in my approach". But this will make me add a lot of work to both DB and DAL.

  • So i wonder if there is an easier way to do this ?? I don't know maybe something like "Log Provider" or SQL Server Triggers or something ??

please support me with your advices even in general ideas about support logging.

...

Edit1:开发者_运维百科

For example suppose that I've "Persons" table and "Person" Model i want to support logging to my person table so i want to know when and what happened to some person data at specific time. I hope the point is clear !.

.

Edit2:

Sorry for my blind and not clear question but i just realize that the Triggers is just the best way to do what i want to do.

sorry again ;}


I'm currently working on an ASP.NET MVC application. This provides the ability to add custom filters to action methods. These are attribute classes inheriting from System.Web.Mvc.ActionFilterAttribute.

I simply decorate any action method I wish to log (or the controller class for all methods) with something like '[Log(LogLevel.High)]'. The LogAttribute class which provides this has a dependancy on my interface ILoggingProvider which contains a Write method (the concrete implementation logs to database). I handle the OnActionExecuted event in the LogAttribute class and use the eventargs to construct the data to pass to the Write method. If you wanted to log results too you could also log the OnResultExecuted event.


The one that comes in mind now is using interception (for example using Unity to intercept instances or types).

I've used this a while ago for trying to fail back to local data (cached from previous requests) when wcf services failed.

So I guess you could intercept calls to your DAL classes and try to log the information in the pre/post events of the pipeline.

For more info you can check this link.

Another approach could be to inject a logger class in your DAL classes (which hopefully have a base DAL class) by using an IoC container (Unity again, or MEF if you're in .NET 4.0).

If something else crosses my mind I`ll let you know.

Regards...


I saw many examples that use "Triggers" to make sort of "History" for a table.

And they made Triggers for "Insert, Update and Delete" to just that tables that they want.

I consider that is very nice especially it doesn't need any interposing from my application.

But i still afraid from Triggers to effect performance !!!

So what is your Advice ??

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜