In ado.net 2.0, datatables are serializable (grin grin grin) so that means you can return them from a web service (though you must fill the tablename property first). Below is what the xml looks like (compared below that, to what the same table looks look like in a dataset)
Not much difference here. But it creates a few less steps on both the web service end and the client end and it bridges a gap for developers. I wonder how many of us tried to return a datatable from a webservice because we didn’t understand the depths of xml serialization and that datatable, up until now, did not implement iSerializable. And then had to do a bit of digging before we found a sentence somewhere that explained that you need to return the dataset. So we save some coding, but also a whole lot of figgerin’ for those folks who don’t need to grok soap and serialization just to move some data around.
<?xml version=”1.0″ encoding=”utf-8″ ?>
– <DataTable xmlns=”http://tempuri.org/“> – <xs:schema id=”NewDataSet“ xmlns=”“ xmlns:xs=”http://www.w3.org/2001/XMLSchema“ xmlns:msdata=”urn:schemas-microsoft-com:xml-msdata“> – <xs:element name=”NewDataSet“ msdata:IsDataSet=”true“ msdata:MainDataTable=”julietable“> – <xs:choice minOccurs=”0“ maxOccurs=”unbounded“> – <xs:element name=”julietable“> <xs:element name=”au_id“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”au_lname“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”au_fname“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”phone“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”address“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”city“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”state“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”zip“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”contract“ type=”xs:boolean“ minOccurs=”0“ />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
– <diffgr:diffgram xmlns:msdata=”urn:schemas-microsoft-com:xml-msdata“ xmlns:diffgr=”urn:schemas-microsoft-com:xml-diffgram-v1“> – <DocumentElement xmlns=”“> – <julietable diffgr:id=”julietable1“ msdata:rowOrder=”0“> <au_id>172-32-1176</au_id>
<au_lname>White</au_lname>
<au_fname>chris</au_fname>
<phone>408 222-1229</phone>
<address>10932 Bigge Rd.</address>
<contract>true</contract>
</julietable>
</DocumentElement>
</diffgr:diffgram>
</DataTable>
————————
<?xml version=”1.0″ encoding=”utf-8″ ?>
– <DataSet xmlns=”http://tempuri.org/“> – <xs:schema id=”NewDataSet“ xmlns=”“ xmlns:xs=”http://www.w3.org/2001/XMLSchema“ xmlns:msdata=”urn:schemas-microsoft-com:xml-msdata“> – <xs:element name=”NewDataSet“ msdata:IsDataSet=”true“> – <xs:choice minOccurs=”0“ maxOccurs=”unbounded“> – <xs:element name=”julietable“> <xs:element name=”au_id“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”au_lname“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”au_fname“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”phone“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”address“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”city“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”state“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”zip“ type=”xs:string“ minOccurs=”0“ />
<xs:element name=”contract“ type=”xs:boolean“ minOccurs=”0“ />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
– <diffgr:diffgram xmlns:msdata=”urn:schemas-microsoft-com:xml-msdata“ xmlns:diffgr=”urn:schemas-microsoft-com:xml-diffgram-v1“> – <julietable diffgr:id=”julietable1“ msdata:rowOrder=”0“> <au_id>172-32-1176</au_id>
<au_lname>White</au_lname>
<au_fname>chris</au_fname>
<phone>408 222-1229</phone>
<address>10932 Bigge Rd.</address>
<contract>true</contract>
</julietable>
</NewDataSet> </diffgr:diffgram>
</DataSet>
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!