MVC3 NHibernate,SQL审核 [英] MVC3 NHibernate, SQL audit
问题描述
我对使用 Fluent NHibernate 作为ORM的 SQL审计模块的实现存在一些误解.因此,情况如下:
I have some misunderstandings about the implementation of an SQL audit module, using as ORM Fluent NHibernate. So here is the situation:
我们正在谈论基于MVC3框架的客户端-服务器应用程序. 假设我们有一个呈现 grid 的方法:
We are talking about a Client-Server application build on MVC3 framework. Suppose there we have a method which renders the grid:
[HttpGet]
public ActionResult ShowGrid()
{
var gridModel = _gridService.GetAllRecords();
return View(gridModel);
}
现在,当有人执行DB Inser/Update/Delete命令时,我希望每个查看该网格的客户端看到内部都有一些更改.
Now when somebody executes a DB Inser/Update/Delete command, I want that every client which views that grid to see that there are some changes inside.
我有3个想法:
1)要编写一个脚本,该脚本每隔 X 秒通过调用数据库进行刷新.进行完整选择即使没有任何更改. 最糟糕的决定
1) To write a script that makes a refresh by calling the database, each X seconds. Making a full Select even if there are no changes yet. Worst decision
2)创建某种触发器,以更新自定义审核表,然后通过比较某些对象状态/最后更新"字段来检查是否有一些新数据. 更好
2) To create some sort of trigger, which updates a custom audit table, and then to check if there is some new data, by comparing some Object State/ LastUpdate fields. Better
3)要使用其他一些工具(没有什么想法),将提供一些解决方案.
3) To use some other tools (no have ideea what tools), that will offer some solutions.
如果有人掌握了一些信息,也许已经存在解决方案,请分享.非常感谢你!
If somebody have some information, maybe there already exists a solution please share. Thank you very much!
推荐答案
最简单的方法是使用NHibernate:
Using NHibernate, the easiest way:
如果您需要实现更复杂的功能,则可以将其与事件侦听器混合使用
If you need implement something more complex you can mix it with event listeners:
或使用:
这篇关于MVC3 NHibernate,SQL审核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!