2
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 上

4

1 回答 1

3

基本上,在执行完所有导航 ( ) 之后,您必须将 where 子句压缩为单个where 子句,如下所示:from

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>接口实现,这意味着这很可能是解释然后由处理翻译查询的任何东西进行优化。

于 2012-07-20T13:20:59.217 回答