.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 ...
随机推荐
- Codeforces Round #541--1131F. Asya And Kittens(基础并查集)
https://codeforces.com/contest/1131/problem/F #include<bits/stdc++.h> using namespace std; int ...
- noip第21课资料
- 迁移桌面程序到MS Store(1)——通过Visual Studio创建Packaging工程
之前跑去做了一年多的iOS开发,被XCode恶心得不行.做人呢,最重要的是开心.所以我就炒了公司鱿鱼,挪了个窝回头去做Windows开发了. UWP什么的很久没有正儿八经写了,国内的需求 ...
- while循环 格式化输出 密码本 编码的初识
第二天课程整理 while 循环 why : while ' 循环' 的意思 what : while 无限循环 how : 1.基本结构 while + 条件 循环的代码 初识循环 while tr ...
- ubuntu 16.04 安装chrome的方法
默认chrome在ubuntu上是没默认安装,安装也不能使用apt-get 来安装,一般会遇到名字无法找到的问题. 摸索了一下,才找到一个比较好的安装方式: 1 从网站: https://www.ch ...
- Maven - 实例-4-依赖传递
这里以Eclipse创建Maven工程来演示. Setp-1 创建Maven项目 File ---> New ---> Maven Project ---> 默认勾选"Us ...
- 爬虫--反爬--css反爬---大众点评爬虫
大众点评爬虫分析,,大众点评 的爬虫价格利用css的矢量图偏移,进行加密 只要拦截了css 解析以后再写即可 # -*- coding: utf- -*- """ Cre ...
- LeetCode--No.007 Reverse Integer
7. Reverse Integer Total Accepted: 153147 Total Submissions: 644103 Difficulty: Easy Reverse digits ...
- [视频]K8飞刀 Discuz! X 系列(1.5 2.5 3.x)产品升级漏洞GetShell教程
K8飞刀 Discuz! X 系列(1.5 2.5 3.x)产品升级漏洞GetShell教程 https://pan.baidu.com/s/1bnv2euz
- 200行代码实现简版react🔥
200行代码实现简版react