score:3

Accepted answer

Basically, you have to condense your where clause into a single where clause after all of the navigations (from) have been performed, like so:

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;

Granted, this doesn't seem optimal, as it would seem that it's going to do cross join all of the tables and then perform the filtering, but remember, you're probably dealing with IQueryable<T> interface implementations, meaning that this will more than likely be interpreted and then optimized by whatever handles the translated queries.


Related Articles