Re: Serializing data set with de-normalized data



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?
>


.



Relevant Pages

  • Re: serialize only a litte part?
    ... BAIS: byte array input stream ... BAOS: byte array output stream ... Yes you can serialize only a part. ...
    (comp.lang.java.programmer)
  • Re: Serialize/DeSerialize Generics List
    ... a bit of a brain fart there: I said "Deserialize" when I meant ... "Serialize" a bunch of times. ... from Array. ... converted to-and-from your hidden List property (converting from lists ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Dynamic serialization of objects with lists or pointers as members
    ... referenced by a pointer to the base class, ... And some of these classes have an array as a member. ... 1- If I want to call each object's serialize() function, ... thenI don't know what will happen when I try to store ...
    (microsoft.public.vc.mfc)
  • Serialize and Unserializa weird behaviour
    ... I found a strange behaviour using serialize and unserialize to persist ... to file a configuration array. ... I'm using a flat text file to store configuration information. ...
    (php.general)
  • Serializing a class with a string[] array
    ... I have a class that contains a string array. ... this object to serialize in the xml output. ... Is there a trick to get a ...
    (microsoft.public.dotnet.xml)