Naming Generic DataContracts in WCF

后端 未结 2 1222
小鲜肉
小鲜肉 2020-12-14 08:40

I am using a Generic Class as a Response Data Contract. All is good and this is streamlining the design of my WCF service significantly.

Each request is given a sta

2条回答
  •  甜味超标
    2020-12-14 09:26

    Ok found the Answer

    You can specify the Serialised version using the following syntax:

    [DataContract(Name = "MyClassOf{0}{1}")]

    class MyClass { }

    So if I had a Class called Response which takes a Generic T parameter I would use

    [DataContract(Name = "ResponseOfType{0}")]

    class Response { }

提交回复
热议问题