.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 ...
随机推荐
- ABP框架系列之三十五:(MVC-Controllers-MVC控制器)
Introduction ASP.NET Boilerplate is integrated to ASP.NET MVC Controllers via Abp.Web.Mvc nuget pack ...
- RISC与CISC比较
1.RISC与CISC的差异 处理器的指令集可简单分为2种,CISC(complex instruction set computer)以及RISC(reduced instruction set c ...
- Git使用方法(精心整理,绝对够用)转载
Git使用方法(精心整理,绝对够用) 一.git客户端(本地仓库)的一些操作 1.设置账户(需要和github账户设置一致) git config --global user.name xxx g ...
- ScriptOJ-flatten2#91
generator的使用 function *flatten2 (arr) { const result = [] function flatten(ar) { ar.map(iter => { ...
- 【pycharm 警告】unittest RuntimeWarning: Parent module ” not found while handling absolute import
Pycharm 2016.2执行单元测试遇到如下问题: RuntimeWarning: Parent module ‘YOUR_MODULE_HERE’ not found while handlin ...
- Vuejs——(1)入门(单向绑定、双向绑定、列表渲染、响应函数)
版权声明:出处http://blog.csdn.net/qq20004604 目录(?)[+] 参照链接: http://cn.vuejs.org/guide/index.html [起步]部 ...
- Git使用01
git 工作区:当前编辑的区域 缓存区:add 之后的区域 本地仓库:commit之后的区域 远程仓库:远程的区域 git init 初始化 git status 查看git的状态 git add 将 ...
- Eclipse 中 Java 代码报版本错误的问题
今天碰到了eclipse中的代码一直报错,后来发现是编译环境的问题,记录一下. 项目build path的JDK版本是开发的时候编译器需要使用到的,例如,如果用的JDK1.4就不能使用泛型. 而jav ...
- Shell-12 -- case
case 是一种匹配选择执行的结构,相当于java中的switch
- 使用jdk的keytool 生成CA证书的方法
一.CA证书生成设置总共分为以下5步: 步骤: 1.根据java的keytool生成CA根证书,放在服务器 2.根据服务器CA根证书导出客户端证书 3.tomcat增加SSL配置 4.客户端IE浏览器 ...