You don't need to avoid anything, ever. Your
are still different object and should be serialized, as soon as you have them in the contract. If they serve the same purpose by some weird reason, don't use the
attribute for one of them.
A side advice: also use namespace URI for all [DataContract] attributes — it can make your data model's XML-based data format world-unique.
Please see my comment below. If my guess is correct, you should understand everything, if you read on the
property or simply try it out:
Are you getting the idea? In particular, this is a very important feature is you want to persists the graph which are not trees. If this is the case, but you fail to use
value for this property, it may cause infinite recursion and, hence, stack overflow.
Again, to understand how it works in terms of XML format, try it out. It uses special references to IDs.