Imagine I've got a data object that makes sense in an OO model, but for serialization I want to have its fields referencing other types replaced with simply an ID, or in some cases, a simple object with a text and an ID.
Is it possible to have the serializer to handle specific fields differently, or do I have to redefine a second data object class from scratch with the simplified fields and use that?
Example:
Person
Guid Id
string Name
List<Person> Siblings
What I want to be serialized:
Person
Guid Id
string Name
List<Guid> Siblings
I would like to only have the one class, Person
, and define the serialization behavior for my service (preferably not at a data type level, since it could be serialized as both XML or JSON).
I know about the support for references in WCF, but in this case I will be referencing other types not included elsewhere in the result set; I only want to include their ids.