![](/img/trans.png)
[英]LINQ query adding orderby makes Skip and Take not work Linqpad
[英]Why this Linq doesn't work (Error translating Linq expression to URI: Can only specify query options (orderby, where, take, skip)
var query = from ch in Client.wcf.context.CashHeading
where ch.Id_customer == customern//cc.Id
from cs in Client.wcf.context.Cash
where cs.Id_cashheading == ch.Id
from gg in Client.wcf.context.Good
where gg.Id == cs.Id_good
select gg.Price.Value;
我正在处理内部错误:
将Linq表达式转换为URI时出错:只能在上次导航后指定查询选项(orderby,where,take,skip)。
我无法理解为什么,完全来源在这里,在GitHub上
基本上,在执行所有导航( from
)之后,必须将where子句压缩为单个 where子句,如下所示:
var query =
from ch in Client.wcf.context.CashHeading
from cs in Client.wcf.context.Cash
from gg in Client.wcf.context.Good
where
ch.Id_customer == customern && //cc.Id
cs.Id_cashheading == ch.Id &&
gg.Id == cs.Id_good
select gg.Price.Value;
当然,这似乎不是最佳的,因为它似乎是它会做交叉连接所有的表, 然后进行过滤,但要记住,你可能处理IQueryable<T>
接口实现,这意味着,这将很可能被解释,然后通过处理翻译的查询来优化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.