Re: Serializing data set with de-normalized data
- From: "W.G. Ryan MVP" <WilliamRyan@xxxxxxxxxxxxxxxx>
- Date: Wed, 24 Aug 2005 08:25:47 -0400
You have very limited ability to affect the XML output and the only things
you really can control are the namespace as well as the format of related
values if you have a datarelation present.
However, I'm not sure I'm following you here. CustomerID I'm assuming is a
column for a given row. If it contains multiple values, they should be
serialized correctly b/c they should be getting treated as one row. There's
no array type for a given value, so if you want to have it behave as an
array, you'll need to create each of those values and separate them with
some delimmiter and ultimately treat them as one value.
If you have them in a child table though , then that should be getting
serialized as well. Is the xml output below the actual output you are
getting? That seems pretty weird unless I"m missing something. Can you
show me the values that are in the dataset or the structure of the dataset?
In short,, if you have a String Array as a datatype in your dataset, that's
not going to work.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclassdatatypetopic.asp
The only way I know of to handle this is to create a child table, or hold
them as one value separated by some delimmiter so that you have 1,2,3,4, 5
as opposed to storing an array of those values that containt 1,2,3,4,5.
Finally, depending on your requirements, you may be able to use a
ComplexType and define your own effective Array, that should serialize
correctly but complex types can't really grow so it may not fit the bill.
You'll probably need to create a datarelation and go the parent/child route.
Finally, remember that if you have the values delimmitted, Xslt basically
gives you the keys to the kingdom as far as how the Xml is output, so you
can do just about anything there. But you'll need to get rid of the array
first.
If I misunderstood though, please let me know and I'll try to address it for
you.
HTH,
Bill
"Stephen Walch" <swalch@xxxxxxxxxxxxx> wrote in message
news:OFSY9PJqFHA.2816@xxxxxxxxxxxxxxxxxxxxxxx
>I have a DataSet where some data items are actually objecy ot type
>string[]. If I output a schema using DataSet.WriteXmlSchema() using , I
>get:
>
> <xs:element name="ItemName" msdata:DataType="System.String[], mscorlib,
> Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
> type="xs:string" minOccurs="0" />
>
> Accessong these items works fine in code:
>
> //C#
> string[] results = (string[])row["ItemName"];
>
> But when I try to use the DataSet.WriteXml() method to serialize the data,
> the output does not contain the desired data:
>
> <CustomerID>System.String[]</CustomerID>
>
> Clearly the serializer is calling the item value's ToString() method
> intread of recognizing that it is a string array and digging deeper. I
> think I understand why; the proper way to structure such a DataSet is to
> normalize it such that "multi-valued" items are stored in a separate table
> with a data relation.
>
> Yet, I have to deal with the DataSet I have. Is there any option for
> overriding how certain items are serialized and deserialized? Or am I
> stuck with writng my own serializer from scratch?
>
.
- References:
- Serializing data set with de-normalized data
- From: Stephen Walch
- Serializing data set with de-normalized data
- Prev by Date: How to select schema?
- Next by Date: combobox DataSource DisplayMember problem
- Previous by thread: Serializing data set with de-normalized data
- Next by thread: daMyDatatable.Update fails for linked dataset tables (using OleDb)
- Index(es):
Relevant Pages
|