Circular Reference exception with JSON Serialisation with MVC3 and EF4 CTP5w

前端 未结 5 1946
一生所求
一生所求 2020-12-10 12:42

I\'m having problems with a circular reference when i try and serialise an object returned via EF4 CTP5. Im using the code first approach and simple poco\'s for my model.

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 13:19

    I had a similar problem with an IIS hosted WCF service and trying to serialize POCO objects with the DataContractJsonSerializer class. The built in JSON serializer does not seem to handle circular references at all. I was able to get around it by handling the serialization myself using the JSON.net serializer, and just returning json strings from my methods. The JSON.net serializer has an option to ignore circular references as json itself does not support them.

提交回复
热议问题