1
Vote

Nested list is generated as a single list - wrong optimalization

description

I have a list within a list in my types.   Criteria contains a list of CriteriaSets which every element contains a list of CriteriaElements. Here is an example xsd:   <?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://noplace.com/" xmlns:tns="http://noplace.com/" elementFormDefault="qualified"> <complexType name="CriteriaElement"> <sequence> <element name="Id" type="string"/> <element name="Value" type="int"/> </sequence> </complexType> <complexType name="CriteriaSet"> <sequence> <element name="CriteriaElements" type="tns:CriteriaElement" maxOccurs="unbounded"/> </sequence> </complexType> <complexType name="Criteria"> <sequence> <element name="Id" type="string" minOccurs="0"/> <element name="Name" type="string"/> <element name="CriteriaSets" type="tns:CriteriaSet" maxOccurs="unbounded"/> <element name="Firma" type="string"/> </sequence> </complexType> </schema>     Now when I run "generate data contract code" class CriteriaSet is not generated at all. Class Criteria constains code:   [System.Xml.Serialization.XmlArrayItemAttribute("CriteriaElements", typeof(CriteriaElement), IsNullable=false)] public System.Collections.Generic.List<CriteriaElement> CriteriaSets   So I get only one list of CriteriaElement. Therefore I loose information how CriteriaElements are grouped into sets. I do not want to change anything in my wsdl as it is approved by my client.   My options for "generate data contract code" are "public properties" and "List<T>" and I still want to keep them set.   I played around with the options and only clearing both options "collections" and "List<T>" generates code that is not satisfying but keeps the information I need. That is what I get: public CriteriaElement[][] CriteriaSets   Adding any more information to CriteriaSet e.g.:   <complexType name="CriteriaSet"> <sequence> <element name="CriteriaElements" type="tns:CriteriaElement" maxOccurs="unbounded"/> <element name="Id" type="string" minOccurs="0"/> </sequence> </complexType>   makes everything work as a miracle and the class CriteriaSet i generated, but it is a dummy element I do not want in my contract.

file attachments

comments