I am having trouble when using List objects:
[DataContract]
public class Recipe
{
[DataMember(Name="Allergies")]
public List<AllergyModel> Allergies { get; set; }
}
[DataContract]
public class AllergyModel
{
public string Allergy { get; set; }
}
How do I make the XML produced not include the AllergyModel node? When I come to read the Recipe parameter, the Allergies list property is null because in the original XML the structure does not have the AllergyModel node.
<Allergies>
<a:AllergyModel>
<a:Allergy>nuts</a:Allergy>
</a:AllergyModel>
<a:AllergyModel>
<a:Allergy>wheat</a:Allergy>
</a:AllergyModel>
</Allergies>