13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 9-6: An application that passes some data to a DataTable object and then persists itto <strong>XML</strong>.So much <strong>for</strong> DataTable objects. Let's see what you can do to serialize to <strong>XML</strong> thecontents of an <strong>in</strong>-memory, possibly filtered, view.Inside the DataView ObjectThe DataView class represents a customized view of a DataTable object. Therelationship between DataTable and DataView objects is governed by the rules of awell-known design pattern: the document/view model. Accord<strong>in</strong>g to this model, theDataTable object acts as the document, and the DataView object acts as the view. Atany moment, you can have multiple, different views of the same underly<strong>in</strong>g data. Moreimportant, you can manage each view as an <strong>in</strong>dependent object with its own set ofproperties, methods, and events.The view is implemented by ma<strong>in</strong>ta<strong>in</strong><strong>in</strong>g a separate array with the <strong>in</strong>dexes of theorig<strong>in</strong>al rows that match the criteria set on the view. By default, the table view isunfiltered and conta<strong>in</strong>s all the records <strong>in</strong>cluded <strong>in</strong> the table. By configur<strong>in</strong>g theRowFilter and RowStateFilter properties, you can narrow the set of rows that fit <strong>in</strong>to aparticular view. Us<strong>in</strong>g the Sort property, you can apply a sort expression to the rows <strong>in</strong>the view. Figure 9-7 illustrates the <strong>in</strong>ternal architecture of the DataView object.Figure 9-7: A DataView object ma<strong>in</strong>ta<strong>in</strong>s an <strong>in</strong>dex of the table rows that match the criteria.When any of the filter properties is set, the DataView object gets from the underly<strong>in</strong>gDataTable object an updated <strong>in</strong>dex of the rows that match the criteria. The <strong>in</strong>dex is asimple array of positions. No row objects are physically copied or referenced at thistime.340

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!