I have this line of code in my WCF Entity Framework code
if (criteria.AccommodationTypes != null && criteria.AccommodationTypes.Count > 0)
result = result.Where(a => criteria.AccommodationTypes[a.Type]);
That is causing this error when executed
LINQ to Entities does not recognize the method 'Boolean get_Item(System.String)' method, and this method cannot be translated into a store expression.
AccommodationTypes is an IDictionary. I can see that the problem is that EF cannot translate my code into SQL and that’s why it’s failing but I can’t see what query I need to write to carry out this functionality.
Thanks,
Sachin
For anyone who has a similar issue in the future, here is how I solved it. I created a list of all the values in the dictionary I was interested in (those for which the corresponding boolean was true) and then performed a contains in the query on that list.