Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What I would do ... produce a couple classes. There's an "audit log" thing that collects a bunch of "audit record" things. Each audit record is either an <strong>Edit</strong> or a <strong>Delete</strong>, and contains the record that was changed and the old value of the object if applicable. </p> <p>Ok, since there will be multiple object types involved (Customer, Product,...), that says to me that these types ought to be generic. </p> <p>This brings me to: </p> <pre><code>public class AuditLog&lt;T&gt; { public int UserID { get; set; } public string LastSaved { get; set;} [XmlArrayItem("Entry")] public List&lt;AuditRecord&lt;T&gt;&gt; Records; } public enum Flavor { Edit, Delete } public class AuditRecord&lt;T&gt; { public AuditRecord() { Stamp = DateTime.Now; } [XmlAttribute("action")] public Flavor Action { get; set;} [XmlAttribute("stamp")] public DateTime Stamp { get; set;} public T Before; public T After; // maybe null } </code></pre> <p>And then for a class like this</p> <pre><code>public class Customer { public string Name { get; set; } public string City { get; set; } public String Country { get; set; } } </code></pre> <p>... you would get a document like this:</p> <pre><code>&lt;AuditLogOfCustomer&gt; &lt;UserID&gt;0&lt;/UserID&gt; &lt;LastSaved&gt;2012 Jun 16 20:42:53&lt;/LastSaved&gt; &lt;Records&gt; &lt;Entry action="Edit" stamp="2012-06-16T20:42:52.9622344-07:00"&gt; &lt;Before&gt; &lt;Name&gt;Sheldon&lt;/Name&gt; &lt;City&gt;Ipswich&lt;/City&gt; &lt;Country&gt;UK&lt;/Country&gt; &lt;/Before&gt; &lt;After&gt; &lt;Name&gt;Sheldon&lt;/Name&gt; &lt;City&gt;London&lt;/City&gt; &lt;Country&gt;UK&lt;/Country&gt; &lt;/After&gt; &lt;/Entry&gt; &lt;Entry action="Delete" stamp="2012-06-16T20:42:52.9642345-07:00"&gt; &lt;Before&gt; &lt;Name&gt;Sheldon&lt;/Name&gt; &lt;City&gt;London&lt;/City&gt; &lt;Country&gt;UK&lt;/Country&gt; &lt;/Before&gt; &lt;/Entry&gt; &lt;/Records&gt; &lt;/AuditLogOfCustomer&gt; </code></pre> <p>code: <a href="http://pastebin.com/PKiEefnX" rel="nofollow">http://pastebin.com/PKiEefnX</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload