登录时,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的更多相关文章

  1. Self referencing loop detected for property 错误

    EF 序列化返回json时 报错:Self referencing loop detected for property 解决方案:在webapiconfig.cs文件中,增加设置: 1.config ...

  2. 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 ...

  3. JSON.NET的Self referencing loop detected with type的原因以及解决办法

    模型中有循环引用是很常见的.例如,以下模型显示双向导航属性: : public class Category : { : public Category() : { : Products = new ...

  4. .NET JSON 转换 Error ” Self referencing loop detected for type“

    在进行实体转换为Json格式报错如下图: Self referencing loop detected for property 'md_agent' with type 'System.Data.E ...

  5. EF关于报错Self referencing loop detected with type的原因以及解决办法

    1)具体报错 { "Message": "出现错误.", "ExceptionMessage": "“ObjectContent` ...

  6. Self referencing loop detected with type

    json.net namespace EFDAL{    using System;    using System.Collections.Generic;    using Newtonsoft. ...

  7. c# json 序列化时遇到错误 error Self referencing loop detected for type

    参考网址:http://blog.csdn.net/adenfeng/article/details/41622255 在写redis缓存帮助类的时候遇到的这个问题,本来打算先序列化一个实体为json ...

  8. Json Self referencing loop detected

    Self referencing loop detected......的错误 解决方案: 1 增加  [JsonIgnore]  过滤关联,使其不参与序列化. 这个方法简单粗暴.但是你就没办法获取关 ...

  9. Newtonsoft.Json转换强类型DataTable错误:Self referencing loop detected with type ......

    问题,在使用Newtonsoft.Json对强类型的DataTable进行系列化时会出现循环引用错误 解决办法,不要直接系列化强类型的DataTable,改为 JsonConvert.Serializ ...

随机推荐

  1. 创建 Mac OS X 10.9 USB 安装盘

    通过 App Store 下载最新的 OS X 10.9 在“应用程序”目录找到下载的 OS X 10.9 安装文件,选中并鼠标右键,菜单中选择“显示包内容” 弹出的 Finder 中进入 Conte ...

  2. linux nVidia driver 304 319 . installation by hand

    It's so painful to install nVidia driver by hand on linux. If you remove it or you want to upgrade b ...

  3. 【Win32API】SendInput ERROR_BUSY 错误原因

    最近需要解决一个Windows上模拟键盘输入的问题, 使用SendInput这个API来实现的.当我从另外一台机器给当前机器发送一条键盘指令时,发现SendInput一直是成功的,但是没有看到任何输入 ...

  4. linux iptable 设置实践

    下面是设置网络时的基本状况: 主机3个网卡: eth0 192.168.0.1/24   内网 eth1 192.168.20.1/24  外网 eth2 192.168.50.1/24  会议室网络 ...

  5. 工作流--JBPM简介及开发环境搭建

    一. 工作流简介 项目中不断的接触工作流,点点滴滴积累了一些,下面把一些学习到的东西整理记录下来. 工作流一般的适用场景:公文流转.行政审批.订单处理.产品研发.制造过程等.用专业一点的语言来描述工作 ...

  6. [C++STDlib基础]关于单字符的操作——C++标准库头文件<cctype>

    网上实例 总结 /* _STD_BEGIN using _CSTD isalnum; using _CSTD isalpha; using _CSTD iscntrl; using _CSTD isd ...

  7. EF框架操作postgresql,实现WKT类型坐标的插入,查询,以及判断是否相交

    1.组件配置 首先,要下载.NET for Postgresql的驱动,npgsql,EF6,以及EntityFramework6.Npgsql,版本号 3.1.1.0. 由于是mvc项目,所以,把相 ...

  8. HTTP could not register URL http://+:86/. 设置VS默认以管理员权限打开

      在使用visual studio 2013启动self host webapi时候碰到下面的错误: 详细错误信息如下: HTTP could not register URL http://+:8 ...

  9. 转]python 结巴分词(jieba)学习

    原文  http://www.gowhich.com/blog/147 主题 中文分词Python 源码下载的地址:https://github.com/fxsjy/jieba 演示地址:http:/ ...

  10. 将前台input中的数据异步传到后台并存入数据库

    将前台input中的数据异步传到后台并存入数据库 先看图: 利用ajax异步交互数据,并不是以json数组的形式将数据传到后台,而是利用字符数组的形式将其传到后台.动态新增每一行数据,将每一列对应的数 ...