Entity framework serialize POCO to JSON

前端 未结 4 1154
旧时难觅i
旧时难觅i 2020-12-20 08:40

I\'m using Ef 4.1 and I\'ve got a POCO object I\'d like to serialize to JSON, I\'ve read there is a problem to do so when using lazy loading but I\'m not sure I can because

4条回答
  •  星月不相逢
    2020-12-20 09:06

    The problem is circular references. An easy way to avoid this is to use Json.Net http://james.newtonking.com/projects/json-net.aspx instead of the default MVC json serializer. The latest version of Json.Net will serialize objects with circular references out of the box. http://james.newtonking.com/projects/json/help/PreserveObjectReferences.html for more info on the problem

提交回复
热议问题