You already mentioned the approach, but I use this attribute
public class ReferencePreservingDataContractFormatAttribute : Attribute, IOperationBehavior { #region IOperationBehavior Members public void AddBindingParameters(OperationDescription description, BindingParameterCollection parameters) { } public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy) { IOperationBehavior innerBehavior = new ReferencePreservingDataContractSerializerOperationBehavior(description); innerBehavior.ApplyClientBehavior(description, proxy); } public void ApplyDispatchBehavior(OperationDescription description, System.ServiceModel.Dispatcher.DispatchOperation dispatch) { IOperationBehavior innerBehavior = new ReferencePreservingDataContractSerializerOperationBehavior(description); innerBehavior.ApplyDispatchBehavior(description, dispatch); } public void Validate(OperationDescription description) { } #endregion }
} ... and links to the operation on the Service, for example:
[OperationContract] [ReferencePreservingDataContractFormat] IList<SomeObject> Search(string searchString);
FYI - I would like to give a loan where it was, but did not write down where I initially saw the above approach.
Edit:
I believe the source code from this blog post .
Christopherous 5000
source share