JSON.NET Error Self referencing loop detected for type

后端 未结 25 2951
我在风中等你
我在风中等你 2020-11-22 02:16

I tried to serialize POCO class that was automatically generated from Entity Data Model .edmx and when I used

JsonConvert.SerializeObject 

25条回答
  •  失恋的感觉
    2020-11-22 02:32

    For me I had to go a different route. Instead of trying to fix the JSON.Net serializer I had to go after the Lazy Loading on my datacontext.

    I just added this to my base repository:

    context.Configuration.ProxyCreationEnabled = false;
    

    The "context" object is a constructor parameter I use in my base repository because I use dependency injection. You could change the ProxyCreationEnabled property anywhere you instantiate your datacontext instead.

    http://techie-tid-bits.blogspot.com/2015/09/jsonnet-serializer-and-error-self.html

提交回复
热议问题