A type can be initialized in two places in the same query, but only if the same properties
The type 'WuZiFenGongSiInfomation.Models.Veiw.UserView' appears in two structurally incompatible initializations within a single LINQ to Entities query. A type can be initialized in two places in the same query, but only if the same properties are set in both places and those properties are set in the same order.
类型“wuzifengongsiinformation.Models.Veiw.UserView”在单个LINQ to Entities查询中以两种结构上不兼容的初始化形式出现。一个类型可以在同一个查询的两个位置初始化,但前提是在两个位置设置了相同的属性并且这些属性的设置顺序相同。
这里说的是有两个查询都用了相同的类型返回,结果这两个类型设置的属性不同,比如有字段差异,一个多些一个少些,则是ef就会报错,解决是两个相同返回类型的查询都要设置相同的字段,相同的个数,不然就会报错
比如下图这样的,EF解析就会报错:
解决办法,不管你有个类型比如图中的图表作者是否需要Uno字段,都要设置启用字段Uno,可以给个默认值
解决办法就是启用第二个红色箭头被注释的//Uno=0,这个行代码