Code sharing for audit log in single table.
See original GitHub issueHi
I was having a requirement to generate report for work done by user on daily basis and the details of actions (Insert/Update/Delete) by user. Initially i was using ICaptureLogRow but i have so many table and i have to create a copy of each table and a log class for each module. My table also changed frequently so maintaining log table and log class was becoming pain for me. So i created custom behaviour to log all changes in single table.
I am sharing code by thinking that it may be helpful for someone else. DBScripts for Table, Stored Procedure and Code file is attached. DB Scripts SQLServer_AuditScript.txt
Code File AuditBehavior.txt
How To Use
- Run the DBScript in your SQL Server Database
- If there is already a column named Identity then inherit your RowClass with IAuditLog Ex:
public sealed class UserRow : LoggingRow, IIdRow, INameRow, IIsActiveRow, IAuditLog
{
}
- If you want to save any other column value as RowId in AuditTable then use following
public sealed class UserRow : LoggingRow, IIdRow, INameRow, IIsActiveRow, IExAuditLog
{
public Int32Field UserId
{
get { return Fields.IdField; }
}
}
Here is screenshot of log table

Hope this will be helpful for someone. Please let me know if you find any improvement in this or have any suggestions.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:8 (3 by maintainers)

Top Related StackOverflow Question
Added the Wiki Page for this. Wiki Page
great effort Thank you for posting the code
But when I apply the code, I see an error in the process of deleting and adding (Object reference not set to an instance of an object) can you help Also, the class mentioned in Namespace (http://using IBS_ACOC.Modules.Common.Enums;) I don’t know what it is / can it be published? There is an error in Namespace (//using IBS_ACOC.DAL;) / Is it related to the error?
Once again thank you
hope for help