Can't use optional parameters when implementing an interface for a WCF

后端 未结 5 795
刺人心
刺人心 2021-01-11 10:19

In my interface I have declared this.

[OperationContract]
[WebGet]
String GetStuff(String beep, String boop = \"too lazy to type\");

I impl

5条回答
  •  暖寄归人
    2021-01-11 10:39

    You can try this, overloading the function.

    [OperationContract]
    MyResponse GetData(); 
    
    [OperationContract(Name = "GetDataByFilter")]
    MyResponse GetData(string filter);
    

    Then another option is to use a DataContract instead of multiple parameters, and set IsRequired to false on the appropriate DataMembers, like explained in this question.

提交回复
热议问题