LINQ has the concept of "suppliers." When working with LINQ on different data sources, different things must be done for identical LINQ queries depending on the data source.
For example, if you want to use LINQ to query a database, you need to convert the LINQ query to an SQL query. When the data source is OData, the request needs to be converted to a URL. There are different providers for each of them, and each supplier supports a different subset of LINQ statements and other language constructs. LINQ-to-SQL, Entity Framework, and LINQ-to-NHibernate are three popular LINQ database access providers.
In your case, you are using WCF data services, which include the LINQ provider for OData. Since there is no way in OData to express the .Any() LINQ operator, an attempt to use it in a query with this provider throws an exception. Using .AsEnumerable() , you are essentially saying to stop using the OData LINQ provider at this point and start using the LINQ-to-Objects provider (which is not technically a provider, but conceptually you can consider it as one). This means that only what precedes .AsEnumerable() will be converted to an OData request, which will retrieve all Deploy objects that match .Where() , and after all of them are passed to the client, the client will execute the command .Any() by checking the number of Deploy entities received. This, of course, is bad, if there are a lot of such objects, this will lead to unwanted data transmission over the network, when all you need is a server (probably a database) to check if they exist. Unfortunately .Any() not supported by OData 1.0 (I don't know about OData 2.0).
Also, OData may not support .ToString() . You may need to directly compare Guid structures, i.e. Create a local variable containing the GUID value that you want to compare:
var g = Guid.Parse("b7db845b-cec4-49af-8f4b-b419a4e44331")`
And then in the request, compare the GUID as follows:
x.HostedEnvironment == g
source share