Auditing
Check out this PLINQO feature video for more information on Auditing!
Widget Connector |
---|
width | 500 |
---|
url | http://www.youtube.com/watch?v=5sLq_gLZ97s&feature=player_embedded |
---|
height | 310 |
---|
|
What data changed, what was it and what is it now! Questions that are asked all the time. When these questions are asked, PLINQO is ready to help provide the answer. When AuditingEnabled is set to true on the data context, PLINQO will capture the change anytime changes are submitted to the database. PLINQO captures only the objects that are changed and only the properties in those objects that were changed everytime changes are submitted to the database. The before and after values are recorded. Context.LastAudit is where this information is held and there is a ToXml() method that makes it easy to turn the AuditLog into xml for easy storage. Here, we change the User and the Task objects, submit the changes and the xml for the audit is displayed. PLINQO auditing will log Inserts, Deletes and Updates and eliminates the work normally required when the decision is made that auditing of data changes is needed.
...
Code Block |
---|
|
using (var context = new TrackerDataContext())
{
Priority p = new Priority();
p.Name = "High!";
context.Priority.InsertOnSubmit(p);
Task t = context.Task.GetByKey(1);
t.Details = "Startup Counterstrike. |
...
...
Project is done";
context.SubmitChanges();
AuditLog audit = context.LastAudit;
} |
...
Code Block |
---|
|
< audit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.codesmithtools.com/datacontext/audit/1.0" >
|
...
< entity action="Insert" type="Tracker.Data.Priority" |
...
>
< key name="Id" type="System.Int32" |
...
>
< value xsi:type="xsd:int" >0< /value |
...
...
>
< property name="Id" type="System.Int32" |
...
>
< current xsi:type="xsd:int" >0< /current >
|
...
...
>
< property name="Name" type="System.String" |
...
>
< current xsi:type="xsd:string" >High!< /current >
|
...
...
>
< property name="Order" type="System.Int32" >
|
...
< current xsi:type="xsd:int" >0< /current |
...
...
...
>
< entity action="Update" type="Tracker.Data.Task" >
|
...
< key name="Id" type="System.Int32" |
...
>
< value xsi:type="xsd:int" >1< /value |
...
...
>
< property name="Details" type="System.String" >
|
...
< current xsi:type="xsd:string" >Startup CounterStrike. |
...
...
Project is done< /current |
...
>
< original xsi:type="xsd:string" >Work overtime to get project started< /original |
...
...
...
...