gpt4 book ai didi

c# - 为什么这个 Linq 不起作用(将 Linq 表达式转换为 URI : Can only specify query options (orderby, 的错误,其中,采取,跳过)

转载 作者:行者123 更新时间:2023-11-30 22:26:48 25 4
gpt4 key购买 nike

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;

我在处理它时遇到内部错误:

Error translating Linq expression to URI: Can only specify query options (orderby, where, take, skip) after last navigation.

我不明白为什么,完整来源 Here, on 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> interface实现,这意味着这很可能会被任何处理翻译查询的人解释和优化。

关于c# - 为什么这个 Linq 不起作用(将 Linq 表达式转换为 URI : Can only specify query options (orderby, 的错误,其中,采取,跳过),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11577458/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com