I have a collection class that I have decorated with a CollectionDataContract. The collection class also has a property on the class that I would like to be passed to the service client. I have tried adding [DataMember] to that property but it didn't add it to the class in the client when I updated.
Any WCF experts out there have any help to offer?
A working solution is posted on my blog:
http://borismod.blogspot.com/2009/04/wcf-collectiondatacontract-and.html
UPD: Thanks, for your comment, Jeff. Here is a summary here of a non generic class. A full generic solution can be found in a new post in my blog: http://borismod.blogspot.com/2009/06/v2-wcf-collectiondatacontract-and.html
[DataContract(IsReference = true)]
public class EntityCollectionWorkaround : ICollection
{
#region Constructor
public EntityCollectionWorkaround()
{
Entities = new List();
}
#endregion
[DataMember]
public int AdditionalProperty { get; set; }
[DataMember]
public List Entities { get; set; }
#region ICollection Members
// Implement here members of ICollection by wrapping Entities methods
#endregion
#region IEnumerable Members
// Implement here members of IIEnumerable by wrapping Entities methods
#endregion
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With