XML • Represent Updates With DiffGrams

Listing 2. The DataGrid generates this ADO.NET DiffGram when you alter one customer record and insert a record for a new customer. Procedural code in the ListsWSUpdate project transforms the DiffGram to Listing 3's CAML batch statement.

<diffgr:diffgram 
      xmlns:msdata="urn:schemas-microsoft-
         com:xml-msdata" 
      xmlns:diffgr="urn:schemas-microsoft-
         com:xml-diffgram-v1">
   <NewDataSet>
      <Items diffgr:id="Items1" 
            msdata:rowOrder="0" 
            diffgr:hasChanges="modified">
         <ID>1</ID>
         <CustomerID>ALFKI</CustomerID>
         <CompanyName>Alfreds 
            Futterkiste</CompanyName>
         <ContactName>Maria Anders</ContactName>
         <ContactTitle>Sales 
            Representative</ContactTitle>
         <Address>Obere Str. 57</Address>
         <City>Berlin</City>
         <PostalCode>12209</PostalCode>
         <Country>Germany</Country>
         <Phone>030-0074321</Phone>
         <Fax>030-0076545</Fax>
      </Items>
   </NewDataSet>
   <diffgr:before>
      <Items diffgr:id="Items1" 
            msdata:rowOrder="0">
         <ID>1</ID>
         <CustomerID>ALFKI</CustomerID>
         <CompanyName>Alfreds 
            Futterkiste</CompanyName>
         <ContactName>Maria Anders-
            Benson</ContactName>
         <ContactTitle>Sales 
            Representative</ContactTitle>
         <Address>Obere Str. 57</Address>
         <City>Berlin</City>
         <PostalCode>12209</PostalCode>
         <Country>Germany</Country>
         <Phone>030-0074321</Phone>
         <Fax>030-0076545</Fax>
      </Items>
      <Items diffgr:id="Items2" 
            msdata:rowOrder="1">
         <ID>108</ID>
         <CustomerID>BOGUS</CustomerID>
         <CompanyName>Bogus 
            Company</CompanyName>
         <ContactName>Joe Bogus</ContactName>
         <ContactTitle>Proprietor</ContactTitle>
      </Items>
   </diffgr:before>
</diffgr:diffgram>