给定这样的 WCF 接口定义,有没有办法从 ComplexObject 响应值中排除属性?
我想排除 ChildObjects 属性。我不想从属性定义中删除 DataMember 属性,因为我需要在另一种情况下对其进行序列化。
[ServiceContract]
public interface IComplexObjectService
{
[OperationContract]
ComplexObject Test(int a);
}
ComplexObject 的定义如下:
[DataContract(IsReference = true)]
public class ComplexObject
{
[DataMember]
public long ObjectCode
{
get { return _ObjectCode; }
set { _ObjectCode = value; }
}
[DataMember]
public List<ComplexObject> ChildObjects
{
get { return _ComplexObject; }
set { _ComplexObject = value; }
}
}