I ran in to a fellow programmer and was discussing a method i needed to write, and in an OOP aspect, the a Dictionary<T,U>
is perfect. But, i voiced concerns about the XML size and structure that it is translated to during serialization. So my buddy, in a very direct manner, said i should be using a wrapper object that contains the key and value, and return a list of them instead of a dictionary. Are there some .NET objects that just shouldnt be serialized over SOAP, and simpler, custom objects should be created instead?
Asked
Active
Viewed 1,613 times
0
-
possible duplicate? http://stackoverflow.com/questions/495647/serialize-class-containing-dictionary-member – aqwert Mar 31 '11 at 21:55
1 Answers
1
The main things you need to worry about are:
- Don't send unnecessary information.
- Dont make too many service calls.
Try to balance size of data against number of calls (optimally reduce both of these to a minimum).
As a rule most people avoid passing data structures which contain complicated logic, such as Dictionary.
Serializing a List is fine (it will be serialized as an IEnumerable).
Don't feel that your data objects have to look like your Entity objects - think of packets of information rather than Entities. When you receive the data at the client end you should convert it into Entity objects.

Greg Sansom
- 20,442
- 6
- 58
- 76