Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When/Why should I not use IsReference=true on my DataContracts?

I understand what is the attribute property IsReference and what it is doing. But I don't understand why/when I should not use it. When is it a bad idea to use IsReference=true?

If my wcf service are .net to .net, is there good reasons to not set IsReference=true?

like image 619
Stéphane Avatar asked Jan 16 '12 07:01

Stéphane


1 Answers

There are at least two reasons to avoid using IsReference:

First there is a performance penalty since all the serializer must perform an identity check for each object that is to be serialized.

Second, the DataContractJsonSerializer cannot serialize objects marked with the IsReference attribute. So if you need to support both Xml and Json then you cannot use it.

Apart from those, I don't see any reason not to use it. After all it does save some precious bandwidth!

like image 122
Rune Grimstad Avatar answered Sep 18 '22 14:09

Rune Grimstad