[英]Entity Framework: The argument to DbIsNullExpression must refer to a primitive or reference type
[英]Why entity framework results are reference type?
This is because items[0].C and items[1].C points to the same object.items[0].C and items[1].C is the object for first row of city table. 这两个 Persons 表条目具有相同的 cityID,因此它们显然指向具有 Id 1 的同一个城市。EF 为每个 Id(主键)创建一个 object。
7 天后,我添加了 AsNoTracking(),一切正常。 所以对象不一样
var items = (from P in db.tbl_Persons
join C in db.tbl_Cities on P.CityID equals C.ID
select new { P, C }).AsNoTracking().ToList();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.