Saving and Loading DataSet s as XML DiffGramsThe XML DiffGram is a format that makes it easy for two parties to refresh a shared data structure without having to transmit the entire data structure over the network. The desktop .NET Framework DataSet supports DiffGrams extensively. Thus, the desktop .NET Framework can use DiffGrams to support the following scenario:
Machine B has used a DiffGram to describe updates to Machine A without having to transmit all of the redundant data back to Machine A. The .NET Compact Framework's DataSet has very limited support for DiffGrams. It does not support the preceding scenario. Nonetheless, the scenario is very important to understand. If you try to write a .NET Compact Framework application that interacts with desktop applications, then you will run into trouble if the desktop applications try to use DiffGrams in the way described in the scenario. The .NET Compact Framework DataSet supports DiffGrams under the following restrictions for reading and writing them:
How to Read a DiffgramThe .NET Compact Framework DataSet can automatically infer that the XML data it reads is a DiffGram. If the file \ADSDiffgram.xml contains a valid DataSet in XML DiffGram format, then the following code will read it: C# System.Data.DataSet l_DataSet = new DataSet(); l_DataSet.ReadXml("\ADSDiffgram.xml"); // l_DataSet automatically realizes that the data is in DiffGram format VB Dim l_DataSet as System.Data.DataSet = new System.Data.DataSet l_DataSet.ReadXml("\ADSDiffgram.xml") ' l_DataSet automatically realizes that the data is in DiffGram format When to Use DiffGramsAs you have noticed, DiffGram support in the .NET Compact Framework DataSet is quite limited. It is present because the level of support is good enough for the .NET Compact Framework to send and receive DataSet s in Web service calls. Web services transmit DataSet s by using the DiffGram representation. When a DataSet is passed as a Web service argument, the DiffGram representation is embedded in a SOAP packet for you automatically. If you write a very advanced application that builds and cracks SOAP packets without using the built-in Web service support described in Chapter 9, "Using XML Web Services," then you may be forced to deal with DiffGrams. However, implementing such an application is beyond the scope of this book. There are no other major advantages to using the DiffGram format when programming with the .NET Compact Framework DataSet . Thus, we will not discuss the DiffGram format in great detail. |