Circular References and WCF

后端 未结 3 1056
挽巷
挽巷 2021-01-12 21:21

I have generated my POCO entities using POCO Generator, I have more than 150+ tables in my database. I am sharing POCO entities all across the application layers including t

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-12 21:44

    I had the same problem and resolved it by excluding the navigation property back to the parent from the DataContract

    [DataContract]
    public partial class Parent
    {
            [Key]
            [DataMember]
            public virtual int ParentId { get; set; }
    
            [DataMember]
            public virtual string ParentName { get; set; }
    
            [DataMember]
            public virtual Child Child { get; set; }
    
    }
    
    [DataContract]
    public partial class Child
    {
            [Key]
            [DataMember]
            public virtual int ChildId { get; set; }
    
            [DataMember]
            public virtual string ChildName { get; set; }
    
            public virtual List Parents {get; set;}
    }
    

提交回复
热议问题