I have a entitydatasource bound to a gridview on my webpage.
In the code behind, I am able to filter and display what I want to the gridview using the WHERE statements of the entitydatasource. One of my where statements filters by using a large OR statement, but the much more logical IN statement does not work.
For example I have employees 1-9 and I want to select employees 1, 4, and 7. In SQL I can get this two ways:
1.
SELECT * FROM table WHERE EmployeeID = 1 OR EmployeeID = 4 OR EmployeeID = 7
2.
SELECT * FROM table WHERE EmployeeID IN (1,4,7)
Both of these statements work perfectly fine for me in SQL
When using the EF, only option 1 works for selecting those particular employees. In order to create this statement, I have a for loop that creates a whereString that end up looking like this:
whereString = "it.EmployeeID = 1 OR it.EmployeeID = 4 OR it.EmployeeID = 7"
EntityDataSource.Where = whereString
If I set my whereString equal to this
whereString = "it.EmployeeID IN (1,4,7)"
it does not work. Why does this where clause that mimics the format used in the SQL code not work?