MVC3 NHibernate, SQL audit

2019-06-03 14:46发布

I have some misunderstandings about the implementation of an SQL audit module, using as ORM Fluent NHibernate. So here is the situation:

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);
}

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.

I have 3 ideas:

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) 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) 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!

1条回答
倾城 Initia
2楼-- · 2019-06-03 14:56

Using NHibernate, the easiest way:

NHibernate Interceptor

If you need implement something more complex you can mix it with event listeners:

Here

Or use:

NHibernate.Envers

查看更多
登录 后发表回答