我有一个我用CollectionDataContract装饰的集合类.集合类还在类上有一个属性,我希望将其传递给服务客户端.我已经尝试将[DataMember]添加到该属性,但是当我更新时它没有将它添加到客户端的类中.
那里的任何WCF专家都有任何帮助吗?
我的博客上发布了一个可行的解决方案:
http://borismod.blogspot.com/2009/04/wcf-collectiondatacontract-and.html
UPD:谢谢,你的评论,杰夫.以下是非泛型类的摘要.完整的通用解决方案可以在我的博客的新帖子中找到: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 }