|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Return Dataset without schemaHi
I want to return a dataset from a webservice and exclude the schema. How can I do this? /Patrik Patrik,
You can't control this in DataSet. You can get around it by creating a new inherited class and overriding this: protected override bool ShouldSerializeTables() { return false; } protected override bool ShouldSerializeRelations() { return false; } You might also need to override MyDataset(SerializationInfo info, StreamingContext context) and protected override void ReadXmlSerializable(XmlReader reader) and protected override XmlSchema GetSchemaSerializable() but you should test this first before doing so. Clue: look at a typed dataset implementation (click Show All Files on the Solution Explorer and look under a Dataset xsd) Actually if you add a new Dataset.xsd to a project it will create a slightly more verbose dataset as above but it will not send schema as you desire. **NB: The problem will be that you cannot read the xml into an empty blank DataSet as the data will be a diffgram which cannot be inferred, so the client will need to load the schema from a file first. This can be done in your MyDataSet(SerializationInfo info, StreamingContext context) constructor before loading the xml stream. Hope that's what you wanted. The only reason I can think why you want to do this is to avoid publishing a TypedDataSet class on the client side, but you need to do this anyway with the above implementation, or that you want to avoid the overhead of using typed datasets, in which case do as I mentioned. The other nice thing is that you could alter the serialization to not generate a diffgram if you don't care about tracking changes. This will give you a slight reduction in xml serialization size. Regards, John Show quote "Patrik" <Pat***@discussions.microsoft.com> wrote in message news:55C0EBEA-C264-4B31-ABC5-3E5A1F9DC4DF@microsoft.com... > Hi > > I want to return a dataset from a webservice and exclude the schema. > How can I do this? > > /Patrik |
|||||||||||||||||||||||