zoukankan      html  css  js  c++  java
  • Self referencing loop detected with type

      json.net


    namespace EFDAL
    {
        using System;
        using System.Collections.Generic;
        using Newtonsoft.Json;
        public partial class MaterielProcedures
        {
            public int Kid { get; set; }
            public Nullable<int> OKid { get; set; }
            public int Node { get; set; }
            public string ProcedureType { get; set; }
            public string ProcedureNeed { get; set; }
            public string Author { get; set; }
            public System.DateTime CreateTime { get; set; }
            public Nullable<System.DateTime> StartTime { get; set; }
            public Nullable<double> PlanHour { get; set; }
            public Nullable<System.DateTime> EndTime { get; set; }
            public Nullable<int> PercentAge { get; set; }
            public string ProcedureState { get; set; }
            public bool IsOut { get; set; }
           
            public  virtual bom_2d  bom_2d { get; set; }
        }
    }

         var   MPtest = conn.MaterielProcedures.Where(X => X.OKid == Kid).ToList();

          string str2 = JsonConvert.SerializeObject(MPtest);  // 报错位置
                   Response.Write(str2);

    Self referencing loop detected with type
    'System.Data.Entity.DynamicProxies.MaterielProcedures_203DBD2B01DBAD67AF86F4C0C0B7C95197B2BF101DB5CE3063BF24A1DEB2DD69'.
    Path 'bom_2d.MaterielProcedures'.

    外键  哦 ,

    官方解说

    http://msdn.microsoft.com/zh-tw/library/cd43263e-441d-4b51-a9d0-440090c2f707

    个人解决方案

            [JsonIgnore]
            public  virtual bom_2d  bom_2d { get; set; }

  • 相关阅读:
    java基础篇2之枚举
    java基础篇1之可变参数,增强for循环,自动装箱
    计算机常用英语
    ThreadLocal
    Tomcat 配置连接池
    数据库连接池
    装饰者模式
    JavaWeb 之事务
    MySql 批处理
    如何将大数据保存到 MySql 数据库
  • 原文地址:https://www.cnblogs.com/bingguang/p/3803587.html
Copyright © 2011-2022 走看看