EF 序列化返回json时 报错:Self referencing loop detected for property 解决方案:在webapiconfig.cs文件中,增加设置: 1.config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling=Newtonsoft.Json.ReferenceLoopHandling.Serializer; 2.Config.Fomatters.JsonFormatter.…
登录时,json序列化用户类时提示错误"Self referencing loop detected for property--",经过5个小时的查找,发现原因可能是,用户类包含了其他类的导航属性(codefirst中用到)导致序列化时出现的循环引用错误 解决办法:将用户类投影到新的表中即可.如下: var user = ubll.GetList(u => u.LoginName == userName && u.Password == pwd).Select(…
错误Error: Request failed with status code 500 ,调试前端没问题,后端也没问题,还报错"连接超时" 在Network中找到错误Self referencing loop detected for property 'xxxx' with type 当我们后端调试一步一步调试也没发现错误在哪里,但是跳转到前端就报错了.前端没有接收到后端传过来的数据,总结了一下: **前端接收问题**前端就是接收**字段名**以及**类型**问题 比如:nAmE,…
模型中有循环引用是很常见的.例如,以下模型显示双向导航属性: : public class Category : { : public Category() : { : Products = new Collection<Product>(); : } : : public int Id { get; set; } : public string Name { get; set; } : public virtual ICollection<Product> Products {…
1)具体报错 { "Message": "出现错误.", "ExceptionMessage": "“ObjectContent`1”类型未能序列化内容类型“application/json; charset=utf-8”的响应正文.", "ExceptionType": "System.InvalidOperationException", "StackTrace"…
在进行实体转换为Json格式报错如下图: Self referencing loop detected for property 'md_agent' with type 'System.Data.Entity.DynamicProxies.md_agent_5F7CB7C257B9164D0D18D2B3E8DA3838A3ED1C7F5D326A56B71D51234B89C401'. Path '[1].md_design[0]'. 原因:实体某些字段关联他实体的字段了 常用解决方案:赋值…
参考网址:http://blog.csdn.net/adenfeng/article/details/41622255 在写redis缓存帮助类的时候遇到的这个问题,本来打算先序列化一个实体为json字符串,存储到redis中. 在序列化的时候就报错了:error Self referencing loop detected for type,从网上看到了这个解决方案. 在序列化的时候加上后面的设置,就可以了,不会序列化实体中实体了. var json = JsonConvert.Seriali…
Self referencing loop detected......的错误 解决方案: 1 增加  [JsonIgnore]  过滤关联,使其不参与序列化. 这个方法简单粗暴.但是你就没办法获取关联的json对象. 2 序列化时,使用如下代码,list是model对象(只适合关联对象较少) (但是经过楼主测试,关联比较多,比较复杂时,还是没卵用,直接卡死.这个问题的原因呼之欲出,也是由于主外键对象互相深度循环,牵涉到的实体层较多,关联对象更多,就不赘述了) JsonSerializerSet…
json.net namespace EFDAL{    using System;    using System.Collections.Generic;    using Newtonsoft.Json;    public partial class MaterielProcedures    {        public int Kid { get; set; }        public Nullable<int> OKid { get; set; }        publi…
问题,在使用Newtonsoft.Json对强类型的DataTable进行系列化时会出现循环引用错误 解决办法,不要直接系列化强类型的DataTable,改为 JsonConvert.SerializeObject(dt.DefaultView.ToTable()); 系列化缺省视图转换出来的DataTable…
问题简介:前段时间做项目时,将取到的entity往Redis cache里存放时报多重引用的错误. Self referencing loop detected for property 'CheckItemCategory' with type. 一.问题详情 1.chectItemCategory与CheckItem实体介绍 2.我们用ef取了List<CheckItemCategory>,以Json的形式存放到redis中.但在JsonConvert.SerializeObject时报多…
一般是访问https时才出现“508 Loop Detected”,idhttp+IdSSLIOHandlerSocketOpenSSL,这个在上篇文章中讲过了. 由于该问题网上资料极少,连外文资料也没卵用,起初我也以为是idhttp的重定向设置问题,但确认过没设置错. idHttp.HandleRedirects := True; 不过相比https,http的话不会出现这个问题,这就很奇怪了,继续测试... 那么发现,访问普通的https是有返回数据的并且没有报“508 Loop Detec…
原址:http://blog.csdn.net/y3wegy/article/details/7840813 最近在研究Hibernate.过程当中碰到了很多问题啊!其中一个就是not found while looking for property错误 Caused by: org.hibernate.MappingException: class main.java.POJO.User not found while looking for property: id 配置文件如下: <?xm…
注:以下问题全部基于版本 © 2019 MLCDZ. Version 4.3.0.0 [20190830]  .net core 的版本为2.2 1.System.InvalidOperationException:“Unable to determine the relationship represented by navigation property 'User.DeleterUser' of type 'User'. Either manually configure the rela…
在做MVC项目时,难免会遇到Json序列化循环引用的问题,大致错误如下 错误1:序列化类型为“...”的对象时检测到循环引用. 错误2:Self referencing loop detected for property '...' with type '...'. Path '[0].x[0]'. 以上错误是因为数据库表关系引起的,比如一对一或多对多,如图: EF里面是这样的,如图: 解决方法: 步骤1: -引用JSON.NET 步骤2: -引用Newtonsoft.Json 步骤3: -J…
NHibernate做.Net应该都不陌生,今天我们就算是温故下这个技术,概念性的东西就不说了,这次主要说本人在实际使用的遇到的问题,比较费解现在就当是记录下,避免以后再犯.本次主要使用的情况是1对N多表关联操作,具体情况如下(给出主要代码): 一.NHibernate配置 (1) 引入动态库 Antlr3.Runtime.dll.NHibernate.dll.Newtonsoft.Json.dll.Iesi.Collections.dll相关动态库,用NuGet导入即可 (2)配置文件 con…
今天在发布接口的时候出突然出现了一个问题,报错代码为: 1 An exception has occurred while using the formatter 'JsonMediaTypeFormatter' to generate sample for media type 'application/json'. 2 Exception message: Self referencing loop detected for property '******' with type '****…
Entity Framework Core allows you to use the navigation properties in your model to load related entities. There are three common O/RM patterns used to load related data. Eager loading means that the related data is loaded from the database as part of…
原文地址:http://www.it165.net/pro/html/201210/3932.html 最近开始研究Web API,运气不错第一个测试项目就遇到问题@@-当新增Control时选择[API Controller woth read/write actions, using Entity Framework]然后使用Northwnd数据库,数据表选择Orders,Order_Details,Products. 前端javascript程序代码如下 01.@section scrip…
查看EF生成的sql的方法 1.通过在context中设置可以追踪EF[版本必须是6.0或以上]中生成的sql public BookServiceContext() : base("name=BookServiceContext") { // 当然也可以输出到其它位置 this.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); } 2.通过使用sqlserver profiler监测RPC completed事…
错误:Self referencing loop detected with type 'System.Data.Entity.DynamicProxies.tbldph_901D48A194FB31357 [Table("tbldph")] public partial class tbldph { public tbldph() { tbldphcaselinks = new HashSet<tbldphcaselink>(); tbldphnotices = new…
Overview 最近被序列化,循环引用的问题,让我浑身酸爽.遇到这种异常是在搭建WebApi的时候,当我返回Linq实例类集合的时候出现的. 下定决心要解决这个问题.循环引用引起的原因是: 比如说:我现在有两个 类 A 和 B 现在 A类中有B类类型的属性存放着B类的对象,而B类中有一个属性,存放置A类型的字段.结果,进行序列化的时候,序列化A的时候,因为要序列化这B类对象的属性,然后去序列化B类型的对象,B类型的对象有一个属性放置A类型的对象,然后又去序列化A ,如此循环往复. 说的可能有点…
前言 本部分描写叙述了EF怎样载入相关实体的细节,而且怎样在你的模型类中处理环形导航属性.(本部分预备了背景知识,而这不是完毕这个教程所必须的.你也能够跳到第五节) 预载入和延迟载入 预载入和延迟载入的英文名称各自是Eager Loading和Lazy Loading. 当EF与关系数据库一同使用时.了解EF是怎样载入相关数据是很重要的. 去查看EF生成的SQL查询也是很有帮助的. 为了追踪SQL,加入下列代码到BookServiceContext构造器中: public BookService…
Exclude all instances of a class from serialization in Newtonsoft.Json Every custom type can opt how it will be serialized. To example, mark the type with [JsonObject(MemberSerialization = MemberSerialization.OptIn)] and then you have to mark somethi…
EF Core 现在不支持多对多映射,只能做2个一对多映射. 比如Product和Category 我现在定义Product和Category是多对多关系. 那么实体定义如下: public class Product { [Key] public int ProdId{ get; set; } public String ProdCode{ get; set; } public String ProdName{ get; set; } public IList<CategoryProduct>…
序列化:JsonConvert.SerializeObject(T) 直接在类的上面添加[Table("表名")] 在类上添加属性[DataContract] 在属性上添加属性[DataMember] ---------------------------------------------------- 序列化转对象: T result= Newtonsoft.Json.JsonConvert.DeserializeObject<T>(myJson); http://bl…
在eclipse中启动tomcat时出现Setting property 'source' to 'org.eclipse.jst.jee.server:你的站点名'   did not find a matching property错误 解决办法: 1.在server控制台内,在服务器上点右键--属性 2.general选项卡中点switch location 这时,location变为:/servers/tomcat6.0 server at localhost.server 3.在pro…
正确写法: @Override @SuppressWarnings("unchecked") public List<Device> queryOSDevice(String cpu){ String sql = null; if(cpu.equals("os_xp")){ sql = "from "+this.clazz.getName()+" this WHERE this.os.id = (select id from…
转载:http://blog.csdn.net/xu_zh_h/article/details/2294233 4 请求失败4xx 4xx应答定义了特定服务器响应的请求失败的情况.客户端不应当在不更改请求的情况下重新尝试同一个请求.(例如,增加合适的认证信息).不过,同一个请求交给不同服务器也许就会成功. 4.1 400 Bad Request 请求中的语法错误.Reason-Phrase应当标志这个详细的语法错误,比如”Missing Call-ID header field”. 4.2 40…
敲代码敲出了个网页错误代码 495. 然后,正常的跑去百度,看了一堆还是没有完整的网页错误代码,应该说国内的环境的网页错误代码表只有官方的那几个,那么只能FQ了. 去到谷歌,一查全是俄语,乐了,明白是毛子的话就笑了笑,别问我为什么笑,笑点就是这么低! 然后,一眼就看到了nginx,之后问题就解决了,495 nginx的ssl错误. 最后附上一个看起来还行的http网页错误代码表 (from 7牛) 标准扩展码 1xx Informational 信息化 100 Continue 继续 101 S…