'Use client side function in QueryFilter
I used a List.Contains method in a query filter in Ef Core 2.2.1. Since the version 3.0, I have the message "query filter cannot be translated" because we have to manually inform EF that the query has to be excuted client side.
Is there a way to force this method to be executed client side ?
Precision : I have multiple query filter on some entities, most of them can be translated to SQL so I want to chose those who are executed client side.
Solution 1:[1]
Finally I used the IList.Contains method instead List.Contains. If you use the List.Contains, you'll get the error. (watched the EF Core source code to understand that...)
Solution 2:[2]
Just use AsEnumerable()
before the part of the query you want to run on the client.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Fabien Dezautez |
Solution 2 | jicawi |