包含路径表达式错误 [英] Include Path expression error

查看:93
本文介绍了包含路径表达式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





Hi,

Expression<Func<SystemUser, object>>[] includeProperties = { x => x.Company.CompanyAddresses.Where(z=>z.AddressTypeId==5).Select(y => y.Address.Country.CountryRegions) };
                    var user = _SystemUserRepository.GetById(userID, includeProperties);







当我执行上述查询时,它会抛出异常,因为Include路径表达式必须引用在类型上定义的导航属性。使用虚线路径作为参考导航属性和Select运算符对于集合导航属性。



如果我从查询中删除where子句,它执行正常。



可以解释原因吗?




while I am executing the above query, it throws exception as "The Include path expression must refer to a navigation property defined on the type. Use dotted paths for reference navigation properties and the Select operator for collection navigation properties."

if I remove "where" clause from query, it executes fine.

could any one explain the reason?

推荐答案

如果我从查询中删除where子句,它执行正常。

这可能是线索。猜测 - 如果没有您的数据,您需要查看集合中符合条件的值。我猜测没有,所以GetById没有传递任何值。
"if I remove "where" clause from query, it executes fine."
That's probably the clue. At a guess - and without your data that's all it can be - you need to look at how many values you have in the collection which match the criteria. I'm guessing that none do, so the GetById is being passed no values.


这篇关于包含路径表达式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆