查询只返回一个结果
嘿,我非常确定我对 lambda 表达式做了一些错误的操作,这使得我只返回一个结果。如果我的查询没有任何问题(它能够返回多个结果),那么我一定在其他地方有错误,我应该能够找到它。如果我的结果应为 or 的第三部分返回多个结果,则仅返回一个结果。我在这里做错了什么吗?
var proQuery = from a in solutionContext.Products
where a.ID == solutionID ||
(a.ParentID == solutionID && a.Versions.All(c => c.VersionNumber == activeNumber)) ||
(a.Product2.ParentID == solutionID &&
a.Versions.All(c => c.VersionNumber == activeNumber))
select a;
如果您需要更多信息,我很乐意提供帮助。
Hey, I am pretty certain I am doing something incorrectly with my lambda expression and that is making it so that I only return a single result. If there is nothing wrong with my query (it has the ability to return multiple results), then I must have an error elsewhere and I should be able to find it. If my results should return more than one result for the third part of the or, only one is being returned. Am I doing something wrong here?
var proQuery = from a in solutionContext.Products
where a.ID == solutionID ||
(a.ParentID == solutionID && a.Versions.All(c => c.VersionNumber == activeNumber)) ||
(a.Product2.ParentID == solutionID &&
a.Versions.All(c => c.VersionNumber == activeNumber))
select a;
If there is anymore information you need, I would be happy to help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里还没有足够的内容供我们继续,但是您确定
All
是正确的并且不应该是Any
吗?如果没有其他信息,这是需要考虑的一件事。There isn't really enough here for us to go on, but are you sure that the
All
s are correct and shouldn't beAny
s? Absent additional information, that's one thing to look at.