相关疑难解决方法(0)

循环引用在将对象序列化为JSON时检测到异常

正如提到的这个帖子,我得到一个JSON序列化错误在序列化的实体框架代理:

序列化"System.Data.Entity.DynamicProxies.PurchaseOrder_446B939192F161CDBC740067F174F7A6059B0F9C0EEE68CD3EBBD63CF9AF5BD0"类型的对象时检测到循环引用.

但不同的是,我的实体中没有循环引用,它只发生在我们的生产环境中.本地一切都很好......

我的实体:

public interface IEntity
{
    Guid UniqueId { get; }
    int Id { get; }
} 

public class Entity : IEntity
{
    public int Id { get; set; }
    public Guid UniqueId { get; set; }
}

public class PurchaseOrder : Entity
{
    public string Username { get; set; }
    public string Company { get; set; }

    public string SupplierId { get; set; }
    public string SupplierName { get; set; } …
Run Code Online (Sandbox Code Playgroud)

c# serialization json entity-framework asp.net-mvc-4

36
推荐指数
3
解决办法
8万
查看次数