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.

database. If all goes well, the DataSet changes are committed us<strong>in</strong>g the DataSetobject's AcceptChanges method.Although COM is still <strong>in</strong>volved, the SqlXmlAdapter object represents a way toarchitecturally improve the batch update mechanism <strong>in</strong> ADO.<strong>NET</strong>. By us<strong>in</strong>gSqlXmlAdapter, you actually obta<strong>in</strong> a DataSet object that is serialized as a DiffGramdirectly to SQL Server and processed entirely on the server. To optimize the bandwidth,you can pass a DataSet object that conta<strong>in</strong>s only changed rows. The GetChangesmethod provides <strong>for</strong> that.NoteUs<strong>in</strong>g GetChanges with ADO.<strong>NET</strong> batch updat<strong>in</strong>g is not asignificant optimization—it simply reduces the total number ofiterations, but the elim<strong>in</strong>ated iterations are no-op by design. Instead,us<strong>in</strong>g GetChanges with SqlXmlAdapter can be a key optimization,as it truly m<strong>in</strong>imizes the amount of data be<strong>in</strong>g transferred from theclient to SQL Server.ConclusionIn this chapter, we have explored the connections between databases (SQL Server2000 <strong>in</strong> particular) and <strong>XML</strong>. Several DBMS systems provide <strong>XML</strong> support <strong>in</strong> various<strong>for</strong>ms. The <strong>in</strong>dustry standard, however, requires that a DBMS provide <strong>for</strong> direct <strong>XML</strong>result sets and accept changes expressed as <strong>XML</strong> streams. SQL Server 2000 adheresto these requirements.The difficulty lies <strong>in</strong> .<strong>NET</strong> and the different connect<strong>in</strong>g model it <strong>in</strong>troduces—.<strong>NET</strong>Framework data providers <strong>in</strong>stead of OLE DB providers. For .<strong>NET</strong> Frameworkapplications, fetch<strong>in</strong>g data as <strong>XML</strong> is much easier and more effective than persist<strong>in</strong>gchanges as <strong>XML</strong>. For COM applications, the same features are more balanced. Thereason is that SQL Server 2000 came out much earlier than the .<strong>NET</strong> Framework, butthe .<strong>NET</strong> Framework still came too soon to allow the managed provider to be designedwith a broader perspective.As a result, the SQL Server managed provider is unaware of <strong>XML</strong> extensions tosupport FOR <strong>XML</strong> queries and their limitations. Incidentally, this feature, comb<strong>in</strong>ed withthe power of .<strong>NET</strong> Framework <strong>XML</strong> readers, produces a really powerful toolkit. Thetruth, however, is that today the SQL Server managed provider is designed andoptimized <strong>for</strong> traditional SQL commands—period.SQL<strong>XML</strong> 3.0 is an add-on conceived to extend the SQL Server 2000 support <strong>for</strong> <strong>XML</strong>.SQL<strong>XML</strong> 3.0 is just that, however; <strong>in</strong> no way does it represent an <strong>in</strong>tegration to the.<strong>NET</strong> Framework managed provider model. For this reason, it is entirely based on COMOLE DB providers. The managed classes are wrappers around the SQL<strong>XML</strong>OLEDBprovider and, as such, require your code to silently jump out of the CLR dur<strong>in</strong>gexecution. This does not mean that you should not use SQL<strong>XML</strong> 3.0—just be aware ofthe managed classes' understandable, but still not optimal, design.Hopes <strong>for</strong> the future? That's easy—my wish is that SQL<strong>XML</strong> 3.0 will be improved and<strong>in</strong>tegrated with the .<strong>NET</strong> Framework managed provider. As a side effect of this<strong>in</strong>tegration, ADO.<strong>NET</strong> should be enriched with a k<strong>in</strong>d of Updategram object specificallydesigned <strong>for</strong> server-side batch updates.In Chapter 9, we'll tackle DataSet serialization and the theme of <strong>XML</strong> serialization <strong>for</strong>key ADO.<strong>NET</strong> objects <strong>in</strong> general, <strong>in</strong>clud<strong>in</strong>g DataTable and DataView objects. We'll alsotake another look at DiffGrams. DiffGrams will be explored <strong>in</strong> depth <strong>in</strong> Chapter 10.322

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

Saved successfully!

Ooh no, something went wrong!