Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当用户选择条件数量时,如何创建查询?
例如:我的数据库中有一个 Customer 表,用户可以选择 1 个或多个城市,屏幕将显示所选城市的客户。
你必须使用Contains:
Contains
int[] selectedCities = {1,2,3}; var query = db.Customer.Where(c => selectedCities.Contains(c.CityId));