How to give same XML Array name for two DataMembers in Datacontract RRS feed

  • Question

  • User435591045 posted

    I am converting DataContract to XML using XmlSerializerFormat.  My DataContract Looks like this:

     public class Service
            public List<Emp>  abc { get; set; }
            public List<Asset> xyz{ get; set; }

    List<Emp>  returns emp Names with Id. List<Asset> returns Asset details. Based on request type (either  Emp/Asset) I use one of the DataMembers. Due to some constraints I cannot keep them in saparate datacontracts. Here issue is it is not allowing me to give same XML node name as Header.

    Desired XML if request type is emp:

    <Emp id=1 name=abc/>	
    <Emp id=2 name=xyz/>

    Desired XML if request type is Asset:

    <Asset name=pqr/>	
    <Asset name=mno/>	

    Please let me know if I am not clear. Thank you.

    Thursday, October 10, 2013 3:14 AM