My repository has List
, List
and List
where an Enrolment has Enrolment.Student and Enrol
Oh the pains of serialization :-> ...
There was never a generic solution for this, I guess that's why MS stripped it out of the Silverlight framework.
I never rely on any automatic serialization mechanisms of the .net framework. For my own models and repositories, I usually know or can easily programmatically determine which properties are simple scalar ones (numbers/strings/etc) and which are links to other objects (as well as which are lists of either).
There are basically 2 scenarios:
1: We want to serialize/transfer only the flat information of objects. In that case I transfer only the respective IDs for properties that link to other objects. The receiver can then make subsequent queries to get all other objects they need.
2: We want to transfer as much information as possible, i.e. deeper nested XML with several levels, mostly for some reporting functionality displaying everything directly using merely some CSS on the XML. In that case, it is actually desired that objects that are the same will be resolved multiple times into the XML tree.
Sometimes I need to tweak the first scenario a little bit in order to avoid too many subsequent query calls, but usually I get along very well. I.e. I have built into our code base that we can specify which additional objects we want to resolve when, and/or it's configured somewhere.