Chapter 10. Stateful Data Serialization

The DataSet object is designed with data disconnection in mind and with the assumption that optimistic concurrency is the default. In a multiple-user environment, optimistic concurrency occurs when applications do not lock a row while reading it. In contrast, a pessimistic form of concurrency involves locking rows at the data source to prevent users from modifying data in a way that affects other users. The DataSet object abstracts from the physical data source and qualifies itself as a superarray component capable of containing in-memory data.

As a container of disconnected data, the DataSet object accepts any sort of update to the rows it contains, so you can add new rows to any child tables, and you can update or delete existing rows. All these changes are persisted in memory and are not passed on to a persistent storage medium until an explicit update operation is conducted. Such an update requires a new connection and applies an array of changes in a single shot. For this reason, a DataSet update operation is often referred to as a batch update. When the batch update is completed, the DataSet in-memory changes are automatically committed to ensure consistency between the in-memory cache and the underlying storage medium.

As a result, each row of data stored in a DataSet object can have a history of changes that applications might be interested in knowing about and exploiting. All this information is irreversibly lost when you serialize a DataSet object to the Microsoft ADO.NET normal form using the standard option of the WriteXml method. (We examined this type of serialization in Chapter 9.)

An alternative XML schema for serializing the contents of a DataSet object is the DiffGram format. The DiffGram format of the WriteXml method can provide a stateful representation of the DataSet contents, as opposed to the stateless nature of the normal form. Because of its ability to preserve the state of the constituent rows, the DiffGram format is also used to remote a DataSet object through both the Microsoft .NET Framework remoting architecture and Web services. But let’s start by taking a closer look at the structure of a DiffGram script.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.111.70