模型中有循环引用是很常见的.例如,以下模型显示双向导航属性: : public class Category : { : public Category() : { : Products = new Collection<Product>(); : } : : public int Id { get; set; } : public string Name { get; set; } : public virtual ICollection<Product> Products {…
在进行实体转换为Json格式报错如下图: Self referencing loop detected for property 'md_agent' with type 'System.Data.Entity.DynamicProxies.md_agent_5F7CB7C257B9164D0D18D2B3E8DA3838A3ED1C7F5D326A56B71D51234B89C401'. Path '[1].md_design[0]'. 原因:实体某些字段关联他实体的字段了 常用解决方案:赋值…
这是今天在实际开发中遇到的一个问题,需求是查询未分类的博文列表(未加入任何分类的博文),之前是通过存储过程实现的,今天用EF实现了,在这篇博文中记录一下. 博文的实体类BlogPost是这样定义的: public class BlogPost { public int Id { get; set; } public string Title { get; set; } //.... public ICollection<BlogCategory> Categories { get; set;…