Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I control the name of generic WCF return types?

I've got a WCF Web Service method whose prototype is:

[OperationContract]
Response<List<Customer>> GetCustomers();

When I add the service reference to a client, Visual Studio (2005) creates a type called "ResponseOfArrayOfCustomerrleXg3IC" that is a wrapper for "Response<List<Customer>>". Is there any way I can control the wrapper name? ResponseOfArrayOfCustomerrleXg3IC doesn't sound very appealing...

like image 771
ilitirit Avatar asked Oct 05 '08 16:10

ilitirit


1 Answers

You can define your own name in the DataContract attribute like this:

[DataContract(Name = "ResponseOf{0}")]
public class Response<T>

Note that in your example the {0} will be replaced and your proxy reference type will be ResponseOfArrayOfCustomer.

More info here: WCF: Serialization and Generics

like image 156
Panos Avatar answered Nov 17 '22 08:11

Panos