Skip to content

6. Data

Bilal edited this page May 22, 2016 · 1 revision

Tracked data is stored in 2 tables. And note that each one has a corresponding DbSet<> property in TrackerContext so you can do all the CRUD you want.

1. AuditLog

Stores entity level tracking information, like when an entity was changed, who changed it, what was the change ( insert /update/ delete ), etc.

2. AuditLogDetails

Stores property level tracking information like, if an entity property was modified what was its old value and what is its new value.

You can query the tracking data using built-in API as follows-

            using (Context ctx = new Context())
            {
                IQueryable<AuditLog> allCarLogs = ctx.GetLogs<Car>();

                Car myCar = ctx.Cars.Single(x => x.Number == "JH-876G");

                IQueryable<AuditLog> myCarLogs = ctx.GetLogs<Car>(myCar.Id);
            }

Also, you have the freedom to query this tracking data manually as follows

Clone this wiki locally