Serialize one to many relationships in Json.net

后端 未结 5 534
盖世英雄少女心
盖世英雄少女心 2020-12-08 08:44

I am using the Entity Framework code first for data access and I have a Company class which has a collection of Employees. The Employee class also has a Company property.

5条回答
  •  囚心锁ツ
    2020-12-08 08:54

    Updated Answer

    You can either:

    • reconfigure json.net to ignore selfreference loops
    • use the [JsonIgnore] Attribute
    • use a custom converter that remove the navigation in the child
    • or you can use Data Transfer Objects

提交回复
热议问题