Circular references preventing serialization of object graph

前端 未结 1 936
孤独总比滥情好
孤独总比滥情好 2020-12-06 00:05

I\'ve got a simple data model involving Weeds and Weed Families.

WeedFamily <-1---*-> Weed (WeedFamily and Weed have a one-to-many relationship)

相关标签:
1条回答
  • 2020-12-06 00:40

    Add [DataContract(IsReference = true)] to the objects that have circular references.

    [Serializable]
    [DataContract(IsReference = true)]
    public class WeedFamily
    
    [Serializable]
    [DataContract(IsReference = true)]
    public class Weed
    

    See http://msdn.microsoft.com/en-us/library/vstudio/hh241056(v=vs.100).aspx

    0 讨论(0)
提交回复
热议问题