Retrieving Objects from SQL Server Using SQLXML and Serialization
July 14, 2004[From 15Seconds.com]
This article will describe how to design a data access layer for a set of entities. You'll learn how to write an XSD schema and design two simple helper classes -- one for reading an XML stream from SQL Server using SQLXML and another for deserializing the XML stream.
SQLXML libraries are free from Microsoft (http://www.microsoft.com/downloads/results.aspx?productID=&freetext=SQLXML&DisplayLang=en)
A common problem for many developers is designing a reusable data access layer that can be easily modified and performs well.
This is just one of many systems I've developed for mapping database tables to objects in order to avoid hard coding classes that go through datareaders and setting properties of objects from results fields.
The idea comes from SQL Server 2000 and its support to return XML as a response to a query. Using XSD schemas I can define the exact structure of that XML (see MSDN: Creating XML Views by Using Annotated XSD Schemas).
I can also serialize/deserialize quite easily any type of object in .NET as XML, so I assume that if SQL Server gives me the right XML structure I can instantiate objects from that.
The article continues at http://www.15seconds.com/issue/040713.htm