【问题标题】:Audit Log to Maintain History Against Records using Repository Pattern.审核日志以使用存储库模式维护记录的历史记录。
【发布时间】:2016-02-03 12:28:22
【问题描述】:

我想对每条记录执行审计日志,所以它看起来像记录的历史记录,所以用户可以查看对其执行的操作,之前的值是多少?当前值是多少?像这样,在 MVC 中使用存储库模式。 有人请帮帮我。

谢谢。

【问题讨论】:

  • 您好,有人知道如何实现吗?

标签: asp.net-mvc c#-4.0 entity-framework-6


【解决方案1】:

免责声明:我是项目的所有者EF+ (EntityFramework Plus)

您可以使用 EF+ Audit 轻松跟踪更改、排除/包含实体或属性以及在数据库中自动保存审核条目。

// using Z.EntityFramework.Plus; // Don't forget to include this.

var ctx = new EntityContext();
// ... ctx changes ...

var audit = new Audit();
audit.CreatedBy = "ZZZ Projects"; // Optional
ctx.SaveChanges(audit);

// Access to all auditing information
var entries = audit.Entries;
foreach(var entry in entries)
{
    foreach(var property in entry.Properties)
    {
    }
}

项目:http://entityframework-plus.net/

文档:http://entityframework-plus.net/audit

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 2016-03-23
    • 2011-03-18
    • 1970-01-01
    • 2012-06-15
    • 2010-12-23
    相关资源
    最近更新 更多