多个实体类之间循环引用,导致栈区溢出 返回

SqlSugar 沟通中
8 412

已经配置了

builder.Services.AddControllers().AddNewtonsoftJson(option =>
{
    option.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
    //忽略循环引用
    option.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
    //不返回值为NULL的属性,甚用啊,数据要很严谨
    //options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
    //不改变字段大小
    //option.SerializerSettings.ContractResolver = new DefaultContractResolver();
});

,不管是

ISugarQueryable<AiAgrWarehoseReqDetailEntity> entities = Db.Queryable<AiAgrWarehoseReqDetailEntity>()
    .Where(lambda).WhereIF(state.NotNullOrEmpty(), x => x.WarehoseReq.ReviewList.Any(y => y.state == state));
obj.list = entities
    .GroupBy(x => new { x.stragrname, x.stragrtype, x.stragrclass, x.strfactory })
    .Select(x => new { x.stragrname, x.stragrtype, x.stragrclass, x.strfactory, intnum = SqlFunc.AggregateSumNoNull(x.intnum) })
    .ToList();

还是

ISugarQueryable<AiAgrWarehoseReqDetailEntity> entities = Db.Queryable<AiAgrWarehoseReqDetailEntity>()
    .Where(lambda).WhereIF(state.NotNullOrEmpty(), x => x.WarehoseReq.ReviewList.Any(y => y.state == state));
obj.list = entities.Includes(x => x.SysItems)
    .ToList();

都能正常运行返回,但是

ISugarQueryable<AiAgrWarehoseReqDetailEntity> entities = Db.Queryable<AiAgrWarehoseReqDetailEntity>()
    .Where(lambda).WhereIF(state.NotNullOrEmpty(), x => x.WarehoseReq.ReviewList.Any(y => y.state == state));
obj.list = entities.Includes(x => x.SysItems)
    .GroupBy(x => new { x.stragrname, x.stragrtype, x.stragrclass, x.strfactory })
    .Select(x => new { x.stragrname, x.stragrtype, x.stragrclass, x.strfactory, intnum = SqlFunc.AggregateSumNoNull(x.intnum), x.SysItems })
    .ToList();

运行起来就报错-1073741571 (0xC00000FD)

热忱回答8