I'm working with an xsd containing a choice element. After I generate the classes (c# using simplified model) I get class with every option of the choice as a property. So far no problems. However as the number of options grows larger, it becomes more cumbersome to determine which choice was made. Is there a better way than using something like reflection to check which property is not null?
A property pointing to the "choosen" property would be nice.
example xsd
<xs:choice maxOccurs="1">
<xs:element name="option1"
type="type1"
maxOccurs="1" />
<xs:element name="option2"
type="type2"
maxOccurs="1" />
<xs:element name="option3"
type="type3"
maxOccurs="1" />
..........
<xs:element name="option999"
type="type999"
maxOccurs="1" />
</xs:choice>
results in:
class xCt
{
option1 {get;set;}
option1 {get;set;}
option1 {get;set;}
....
option999 {get;set;}
}
Maybe my question is the result of inherently bad schema design, but I cannot figure out a different route.
A ficticious example of this is: consider the car repair shop. Every order contains a single repair. But you can choose that one repair from many different repairs. Every repair has different requierments (paramters/suboptions). The options need to be validated so name value pairs and such generalizations are not allowed.
I thought about adding an attribute that specifies the choice made, but there seems no way to link that to the actually chosen element. So it would be up to the user to fill such a attribute correctly and I want to avoid anything that results in easy user error.
Any suggestions appreciated.