codefirst mvc Self referencing loop detected for property
登录时,json序列化用户类时提示错误“Self referencing loop detected for property……”,经过5个小时的查找,发现原因可能是,用户类包含了其他类的导航属性(codefirst中用到)导致序列化时出现的循环引用错误
解决办法:将用户类投影到新的表中即可。如下:
var user = ubll.GetList(u => u.LoginName == userName && u.Password == pwd).Select(u => new
{
u.ID,
u.LoginName,
u.Password,
u.Role,
u.Tel,
u.UserName,
u.DelFlag,
u.Email,
u.Gender,
u.CompanyID,
u.Address,
u.CreateDataTime
}).FirstOrDefault(); string UserData = SerializeHelper.Instance.ToJson(user);//序列化用户实体
codefirst mvc Self referencing loop detected for property的更多相关文章
- Self referencing loop detected for property 错误
EF 序列化返回json时 报错:Self referencing loop detected for property 解决方案:在webapiconfig.cs文件中,增加设置: 1.config ...
- Request failed with status code 500以及自引用循环Self referencing loop detected for property ‘xx‘ with type
错误Error: Request failed with status code 500 ,调试前端没问题,后端也没问题,还报错"连接超时" 在Network中找到错误Self r ...
- JSON.NET的Self referencing loop detected with type的原因以及解决办法
模型中有循环引用是很常见的.例如,以下模型显示双向导航属性: : public class Category : { : public Category() : { : Products = new ...
- .NET JSON 转换 Error ” Self referencing loop detected for type“
在进行实体转换为Json格式报错如下图: Self referencing loop detected for property 'md_agent' with type 'System.Data.E ...
- EF关于报错Self referencing loop detected with type的原因以及解决办法
1)具体报错 { "Message": "出现错误.", "ExceptionMessage": "“ObjectContent` ...
- Self referencing loop detected with type
json.net namespace EFDAL{ using System; using System.Collections.Generic; using Newtonsoft. ...
- c# json 序列化时遇到错误 error Self referencing loop detected for type
参考网址:http://blog.csdn.net/adenfeng/article/details/41622255 在写redis缓存帮助类的时候遇到的这个问题,本来打算先序列化一个实体为json ...
- Json Self referencing loop detected
Self referencing loop detected......的错误 解决方案: 1 增加 [JsonIgnore] 过滤关联,使其不参与序列化. 这个方法简单粗暴.但是你就没办法获取关 ...
- Newtonsoft.Json转换强类型DataTable错误:Self referencing loop detected with type ......
问题,在使用Newtonsoft.Json对强类型的DataTable进行系列化时会出现循环引用错误 解决办法,不要直接系列化强类型的DataTable,改为 JsonConvert.Serializ ...
随机推荐
- HTML5学习+javascript学习:打飞机游戏简介以及Model层
本着好记性不如烂博客以及分享成功的喜悦和分享失败的苦楚,今天我来分享下一个练手项目:打飞机游戏~从小就自己想做游戏,可是一直没有机会.HTML5给了我们这个平台,这个平台可以有很多以前想都不敢想的东西 ...
- Ubuntu snappy is lame
ubuntu has just announced that snappy will replace 'apt' as the next generation of package manager f ...
- 关于code reivew
关于code reivew 先谈谈三个code review的关键因素: 一.创建review要简单 code reivew是一个程序员日常工作中经常做的一件事,理论上来讲,任何一个将要submit到 ...
- vsftp FTP服务器外网访问设置
引用: linux中VSFTP无法从外网访问问题! http://blog.csdn.net/zbulrush/article/details/841978 原文: FTP协议有两种工作方式:PORT ...
- 1.JSP入门
一.JSP基础 1.JSP概述 JSP(Java Server Pages)是JavaWeb服务器端的动态资源.它与html页面的作用是相同的,显示数据和获取数据. JSP = html + Jsp脚 ...
- spring_boot打jar包及打包错误的解决方法
问题产生及解决 对于刚接手spring_boot的人,可能会感觉到很茫然无措,看到书上写的spring_boot是直接打包成jar包,使用java -jar *运行.然而却不知道该怎么打包.而创建sp ...
- Chrome使用小技巧-多用户登录、直接打开隐身模式窗口
在开发过程中,有时候需要打开2个chrome,各自登录一个账号来做测试,正常情况下由于同一用户下的chrome共享cookies的原因,是没办法登录2个账号的. 这种情况,可以找到chrome图标,点 ...
- Libevent核心原理
Libevent 是一个事件驱动框架, 不能仅说他是一个网络库. notejs就是采用与libevent类似的libev来做核心驱动的. Libevent支持三种事件:io事件.信号事件.时间事件 ...
- [ios2]iphone编程中使用封装的NSLog来打印调试信息 【转】
使用NSLog的一个风险是:它的运行会占用时间和设备资源. 简单而粗暴的解决方案是:在release前,将所有的NSLog注释掉.简单有效,但副作用是:下次你要调试时,又得将NSLog一个个取消注释. ...
- dubbo学习笔记
一.zookeeper在Dubbo中扮演角色 流程:1.服务提供者启动时向/dubbo/com.foo.BarService/providers目录下写入URL2.服务消费者启动时订阅/dubbo/c ...