简体   繁体   English

制作表格行的多个版本((或历史记录))的最佳方法是什么

[英]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". 我要为要支持记录的每个表向数据库中添加新表,然后通过DAL“ EF in my approach”处理该表。 But this will make me add a lot of work to both DB and DAL. 但这将使我在DB和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 ?? 我不知道类似“日志提供程序”或SQL Server触发器之类的东西吗?

please support me with your advices even in general ideas about support logging. 请就您的建议提供支持,即使是关于支持日志的一般想法。

... ...

Edit1: 编辑1:

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 . 例如,假设我有“ Persons”表和“ Person” Model,我想支持记录到我的人员表, 以便我想知道特定时间某些人员数据何时以及发生了什么 I hope the point is clear !. 我希望这一点很清楚!

.

Edit2: 编辑2:

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 ;} 再次抱歉 ;}

The one that comes in mind now is using interception (for example using Unity to intercept instances or types). 现在想到的是使用拦截(例如,使用Unity拦截实例或类型)。

I've used this a while ago for trying to fail back to local data (cached from previous requests) when wcf services failed. 我之前曾用它来尝试在wcf服务失败时恢复到本地数据(从以前的请求缓存)。

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. 因此,我想您可以拦截对DAL类的调用,并尝试将信息记录在管道的事前/事后事件中。

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). 另一种方法可能是通过使用IoC容器(再次是Unity,如果您使用.NET 4.0,则是MEF)在DAL类(希望有一个DAL类)中插入记录器类。

If something else crosses my mind I`ll let you know. 如果我有其他事情想念,我会通知您。

Regards... 问候...

I'm currently working on an ASP.NET MVC application. 我目前正在研究ASP.NET MVC应用程序。 This provides the ability to add custom filters to action methods. 这提供了将自定义过滤器添加到操作方法的功能。 These are attribute classes inheriting from System.Web.Mvc.ActionFilterAttribute . 这些是从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)]'. 我只是简单地用“ [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). 提供此功能的LogAttribute类依赖于我的接口ILoggingProvider ,该接口包含Write方法(具体的实现日志记录到数据库)。 I handle the OnActionExecuted event in the LogAttribute class and use the eventargs to construct the data to pass to the Write method. 我在LogAttribute类中处理OnActionExecuted事件,并使用eventargs构造数据以传递给Write方法。 If you wanted to log results too you could also log the OnResultExecuted event. 如果您也想记录结果,则还可以记录OnResultExecuted事件。

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 ?? 那么您有什么建议?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 允许用户在iPhone上加载其历史记录的最佳方法是什么? - What's the best way to allow users to load their history on iPhone? 针对多个.NET框架版本的最佳方法是什么? - What's the best way to target multiple versions of the .NET framework? 基于关联计算表中行之间相似度的最佳方法是什么? - What's the best way to calculate similarity between rows in a table based on association? 在多个对象之间共享对象实例的最佳方法是什么? - What's the best way to share an instance of an object across many objects? 将多对多表与另一个表关联的最佳实践是什么? - What's the best practice for associating many-to-many table with another table? 在ASP.Net中处理web.config文件版本的最佳方法是什么? - What's the best way to handle web.config file versions in ASP.Net? 从string []制作二维数组的最佳方法是什么? - What's the best way to make two dimensional array from string[]? 用箭头制作数字选择器的最佳方法是什么? - What's the best way to make a number picker with arrows? 使方法异步运行的最佳方法是什么? - What's the best way to make method run async? 使对象知道他在列表中的位置的最佳方法是什么? - What's the best way to make object aware of his place in a list?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM