C# - LINQ Statements with OR clauses
- by user70192
Hello,
I am trying to use LINQ to return a list of tasks that are in one of three states. These states are:
10 - Completed
11 - Incomplete
12 - Skipped
The state is available through a property called "TaskStateID". I can do this in LINQ with just one state as shown here:
var filteredTasks = from task in tasks
select task;
// Do stuff with filtered tasks
string selectedComboBoxValue = GetFilterComboBoxValue();
if (selected ComboBoxValue == 3)
{
filteredTasks = filteredTasks.Where(p => p.TaskStateID == 10); // How do I use an 'OR' here to say p.TaskStateID == 10 OR p.TaskStateID == 11 OR p.TaskStateID == 12
}
As shown in the comment above, how do I use an 'OR' in a LINQ statement to say p.TaskStateID == 10 OR p.TaskStateID == 11 OR p.TaskStateID == 12?
Thank you