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.
Source: stackoverflow.com
Related Articles
- Why this Linq doesn't work (Error translating Linq expression to URI: Can only specify query options (orderby, where, take, skip)
- Unit test error : This function can only be invoked from LINQ to Entities
- LINQ related error "Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context
- Why doesn't this LINQ Select expression work
- Small Linq expression doesnt work
- Linq update error Only primitive types or enumeration types are supported in this context
- How can I make this SQL query work in LINQ lambda expression
- Convert this linq code to expression
- Why does my linq expression only work when broken into two parts?
- C# LINQ: DbFunctions.TruncateTime throw error This function can only be invoked from LINQ to Entities
- Error LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression
- C# LINQ GroupBy error Only one expression can be specified in the select list
- LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression
- How does LINQ expression syntax work with Include() for eager loading
- LINQ to Entities does not recognize the method 'Int32 Int32(System.String)' method, and this method cannot be translated into a store expression
- convert this LINQ expression into Lambda
- LINQ to Entities does not recognize the method 'Int32 ToInt32(System.Object)' method, and this method cannot be translated into a store expression
- Is there some sort of syntax error with this LINQ JOIN?
- LINQ to Entities does not recognize the method 'Int32 Parse(System.String)' method, and this method cannot be translated into a store expression
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- Does this LINQ code perform multiple lookups on the original data?
- Reference required error only when using LINQ
- Entity Framework Linq Query to List - Error when using contains: Only primitive types, enumeration types and entity types are supported
- Paging Error :The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'
- How to reuse a linq expression for 'Where' when using multiple source tables
- linq exception : This function can only be invoked from LINQ to Entities
- How does this LINQ Expression work?
- LINQ Source Code Available
- How does this linq code that splits a sequence work?
- multiple orderby in this linq code
- EntitySet vs Table query performance in LINQ2SQL
- Converting WPF to Windows Store App Listbox issue
- Get data by filtering and grouping LINQ query
- How to enumerate through list of Func<TSource,TResult> to filter collection
- Passing an expression to a method in NHibernate results in Object of type 'ConstantExpression' cannot be converted to type 'LambdaExpression'
- C# how do I implement inheritance using linq?
- Sort collection by first item of sub list in Entity Framework
- Convert a string to Linq.Expressions or use a string as Selector?
- Creating Models in ASP.NET MVC
- Query language for Entity Framework
- C# MongoDB Driver: Querying Array of Authors for partial or complete match on author full name
- Seemingly simple LINQ query is throwing me off. I want all items in array A unless it exists in array B
- LINQ: How i can user where condition multi value by array string?
- How to match case-sensitive username and password
- Get PropertyInfo from multiple property objects found in an Expression object
- LINQ Sort DataTable based on 2 columns
- Is it possible to return IQueryable<SomeClass> to a IQueryable<T> method?
- How to sort class list by integer property?
- Mapping values of grouped query?
- GroupBy String and Count in LINQ