Hi PCC,
A very interesting design decision indeed. Here's my
$0.02 -
I've used both ways in different projects too.A couple of
things that you might want to consider :
1)What is the format of the XML data expected by the
client? Do you have complete freedom to define the
expected schema the way you want or should it conform to a
particular specification? Converting the Dataset to XML
generates alot of extra XML stuff that you might not
really need and you might want to think of using an XSL.
IF that does happen, then it might help to use a SQL
template at the DB level and apply the XSL there. Of
course SQL Managed clases also guve you the ability to do
all this on the clent-side if server load is a concern.
2) If you are absolutely sure that all u need to output is
XML, then why use a dataset? Why not just use
SqlXmlcommand.ExecuteXmlReader to get the XML stream back?
3) If you think that at some point of time you might need
to use the data to perform databinding using ASP.NET
controls etc., then it makes sense to stick to using a
dataset (the other option of course is using XML data
islands on IE client-side OR using an XML deserializer to
create an object out of your XML OR rad in the XML in the
dataset I guess :-))
-----Original Message-----
I am writing a data access layer for a web service. Data
from the webservice is to be returned as XML. My design dilemma is
this...
Should I be returning XML from my stored procedures using
the "for xml"clause or loading the data into a DataSet in the data
access layer and thenoutputting XML from the dataset as the response? All my
sprocs are simpleCRUD spocs just to keep maintenance easy.
My own bias is to output XML from the DataSet after I
have loaded it in fromthe sproc. That said, my real question is if I am not
really doing anythingwith the data until it ends up in a DataSet within the
Business ObjectLayer, why should I bother to load it into a DataSet in
the Data AccessLayer and then serialize it as XML when I can get XML
string from thedatabase?
You can tell I am a little lost and confused here. You
advice is greatlyappreciated. I know how to do both, but am not sure
which is best in thelong run. Thank you.
.