开发者

WCF circular references in data contract

I have a WCF contract with circular references. For a simple parent-child relationship, the solution is pretty simple with .NET 3.5SP1 or greater - the IsReference property of a DataContract (this page has a good explanation).

However, my relationships are three levels deep: grandparent <-> parent <-> child. A "grandparent" has many "parents" and a "parent" has many "children". To get the grandparent <-> parent relationship working, I have IsReference set on the grandparent - no problem. But in order to get the parent <-> child 开发者_运维百科relationship working, "parent" needs to be IsReference as well. As soon as I set that, my service fails - I imagine the problem is that the serializer doesn't know what to do when both the "grandparent" and "parent" are IsReference.

Is there any way to fix this with IsReference or do I ned to pursue a different solution?


Stupid mistake on my part. The "parent" is an abstract class and I had only tried marking one of it's subclasses with IsReference when I needed to mark the abstract class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜