To translate an expression into a database query, the database must somehow know the contents of your dictionary and have access to it from the query. There is no dictionary mechanism in SQL, but it doesnโt matter because you donโt need a dictionary, because you are just looking for keys whose value is a specific constant. You can include this key set in the list and see if this list contains what you are looking for:
var groupsList = (from kvp in groupsMap // find all keys in groupsMap where kvp.Value == true // where the value is set to True select kvp.Key).ToList(); IQueryable<HotelTravel> groupq = from hotel in qHs join hp in qHps on hotel.HotelTravelId equals hp.HotelTravelId where !string.IsNullOrEmpty(hp.GroupName) && groupsList.Contains(hp.GroupName) select hotel;
I suspect that in fact you do not have an empty string as a key in your dictionary, which means that you can get rid of the IsNullOrEmpty call and just have where groupsList.Contains(hp.GroupName) .
source share