Serializing strongly typed dataset with extra column
I have a strongly typed dataset with a strongly typed datatable which i pass to my wcf service. I have added an extra 开发者_如何学编程column runtime on this table which is not in the xsd.
When i debug on the server side the wcf operation receives the dataset and datatable, but the extra column and its value isn't a part of it anymore.
I think it has something to do with the serialization of the dataset, but how can I solve this problem without strongly type the column?
thanks in advance
Serialization is the process of converting some object in memory into XML and de-serialization takes that XML and turns it back into an object. The structure of that object is dictated in this case by your strongly typed data set.
You've added new stuff to the object on the client side, but you haven't told the server side what to do with that stuff, so when the XML is deserialized, the extra stuff is tossed away.
Since you don't want to strongly type the additional data, you can derive a new class (bar) from your typed data table (foo) and add the element to it, and make it serializable, then on the server when you deserialize, deserialize into your derived class. Since the derived class bar IS by definition foo, the data set should accept it for data operations but you can still work with your new element as bar.
精彩评论