.NET JSON 转换 Error ” Self referencing loop detected for type“
在进行实体转换为Json格式报错如下图:
Self referencing loop detected for property 'md_agent' with type 'System.Data.Entity.DynamicProxies.md_agent_5F7CB7C257B9164D0D18D2B3E8DA3838A3ED1C7F5D326A56B71D51234B89C401'. Path '[1].md_design[0]'.
原因:实体某些字段关联他实体的字段了
常用解决方案:赋值给新对象再转换成Json,例如下图:
var data = ServiceLocator.GetService<ITestBO>().GetFilteredList(p => p.IsDel == && p.RefType == ).Select(o=>new { ID=o.ID,Name=o.Name }); //选择某些字段,投影到新的类型对象
var json = JsonConvert.SerializeObject(data);
.NET JSON 转换 Error ” Self referencing loop detected for type“的更多相关文章
- c# json 序列化时遇到错误 error Self referencing loop detected for type
参考网址:http://blog.csdn.net/adenfeng/article/details/41622255 在写redis缓存帮助类的时候遇到的这个问题,本来打算先序列化一个实体为json ...
- JSON.NET的Self referencing loop detected with type的原因以及解决办法
模型中有循环引用是很常见的.例如,以下模型显示双向导航属性: : public class Category : { : public Category() : { : Products = new ...
- Self referencing loop detected with type
json.net namespace EFDAL{ using System; using System.Collections.Generic; using Newtonsoft. ...
- EF关于报错Self referencing loop detected with type的原因以及解决办法
1)具体报错 { "Message": "出现错误.", "ExceptionMessage": "“ObjectContent` ...
- Newtonsoft.Json转换强类型DataTable错误:Self referencing loop detected with type ......
问题,在使用Newtonsoft.Json对强类型的DataTable进行系列化时会出现循环引用错误 解决办法,不要直接系列化强类型的DataTable,改为 JsonConvert.Serializ ...
- Json Self referencing loop detected
Self referencing loop detected......的错误 解决方案: 1 增加 [JsonIgnore] 过滤关联,使其不参与序列化. 这个方法简单粗暴.但是你就没办法获取关 ...
- ef entity转json引起的Self referencing loop
问题简介:前段时间做项目时,将取到的entity往Redis cache里存放时报多重引用的错误. Self referencing loop detected for property 'Check ...
- codefirst mvc Self referencing loop detected for property
登录时,json序列化用户类时提示错误"Self referencing loop detected for property--",经过5个小时的查找,发现原因可能是,用户类包含 ...
- Self referencing loop detected for property 错误
EF 序列化返回json时 报错:Self referencing loop detected for property 解决方案:在webapiconfig.cs文件中,增加设置: 1.config ...
随机推荐
- 知名公司的GitHub地址
GoogleGoogle[https://github.com/google]( https://github.com/google) Google Sampleshttps://github.com ...
- 原生js获取元素的子元素
//使用firstChild //但是下面这种因为有空格,也算其子元素 <lable> <span id="onlinePerson" name="pe ...
- 执行PowerShell脚本的时候出现"在此系 统上禁止运行脚本"错误
使用get-executionpolicy查看当前的脚本执行策略, 默认是Restricted, 也就是不允许任何脚本运行. 此时应该使用set-executionpolicy remotesigne ...
- 解决eclipse部署maven时,src/main/resources里面配置文件加载不到webapp下classes路径下的问题
解决eclipse部署maven时,src/main/resources里面配置文件加载不到webapp下classes路径下的问题. 有时候是src/main/resources下面的,有时候是sr ...
- 《你不知道的javascript》读书笔记1
概述 放假读完了<你不知道的javascript>上篇,学到了很多东西,记录下来,供以后开发时参考,相信对其他人也有用. js的工作原理 引擎:从头到尾负责整个js的编译和运行.(很大一部 ...
- python中的数字取整(ceil,floor,round)概念和用法
python中的数学运算函数(ceil,floor,round)的主要任务是截掉小数以后的位数.总体来说 就是取整用的.只是三者之间有微妙的区别: floor() :把数字变小 ceil() : ...
- 机器学习基石笔记:06 Theory of Generalization
若H的断点为k,即k个数据点不能被H给shatter,那么k+1个数据点也不能被H给shatter,即k+1也是H的断点. 如果给定的样本数N是大于等于k的,易得mH(N)<2N,且随着N的增大 ...
- .NET手记-Autofac进阶(传递注册参数 Passing Parameters to Register)
当你注册组件时,可以为组件服务传入一系列参数,用于服务解析时使用. 可使用的参数类型 Available Parameter Types Autofac提供了集中参数匹配类别: NamedParame ...
- PyTorch(二)Intermediate
Convolutional Neural Network import torch import torch.nn as nn import torchvision import torchvisio ...
- VueRouter 源码深度解析
VueRouter 源码深度解析 该文章内容节选自团队的开源项目 InterviewMap.项目目前内容包含了 JS.网络.浏览器相关.性能优化.安全.框架.Git.数据结构.算法等内容,无论是基础还 ...