Nick
Nick

Reputation: 4223

WCF - Generic Dictionary Name Problems

So, I'm consuming a WCF service where a colleague has created functions like this:

<OperationContract()>
Function GetRelationshipsGroupedByClass(ByVal objId As Integer, ByVal showDeleted As Boolean) As Dictionary(Of String, List(Of Relationship))

When I create the service reference in my asp.net application the return type is no longer a dictionary but

ArrayOfKeyValueOfstringArrayOfRelationshipQknDUPatKeyValueOfstringArrayOfRelationshipQknDUPat

Is there any way of giving WCF a custom name to call this instead of this crazy name? Or am I going to have to rewrite all the functions that use generic dictionaries to output custom data contracts instead?

Upvotes: 2

Views: 79

Answers (1)

The other other Alan
The other other Alan

Reputation: 1908

Because Dictionaries are not inherently serializable into XML , WCF converts it into an array - the array you see in your service reference. You may choose to create your own serializable dictionary - here's one, or use custom data contracts as you suggested.

Upvotes: 1

Related Questions