'Build a where statement from a list in Entity Framework

I have a list of strings that I want to use to create a where statement in Entity Framework. For example if I have a list of strings.

List<string> cars = = new(){"car1","car2", "car3"};

I want to build a where clause dynamically from the list

query = query.Where(a => a.car == "car1" || a.car == "car2" || a.car == "car3");


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source