Reputation: 970
I want to get a list of requisitions on dashboard page which is based on condition. The condition is list should show requisition which is assigned to user and has 'started' status. It shows perfectly with this query.
if(p.Name == "mypendingtask") {
int x = Int32.Parse(p.Value);
linqQry = linqQry.Where(it => it.RequisitionTasks.Count(t => t.AssignedTo == x && t.Status == "Started" ) > 0);
}
But further I want to also display requisitions which are reassigned to user, but here it shows the requisition to all users.
if(p.Name == "mypendingtask") {
int x = Int32.Parse(p.Value);
linqQry = linqQry.Where(it => it.RequisitionTasks.Count(t => t.AssignedTo == x && t.Status == "Started" || t.Status == "Reassigned") > 0);
}
I'm stuck here, help would be really appreciated.
Upvotes: 0
Views: 81
Reputation: 2738
You can use an array for your string values to compare against and just use the "Contains" function:
string[] values = { "Started", "Reassigned", "Other" };
var query = query.Where(t => values.Contains(t.Status));
Upvotes: 1
Reputation: 3124
You need brackets in your condition:
t.AssignedTo == x && (t.Status == "Started" || t.Status == "Reassigned")
Because && operator has higher precedence than operator ||.
Upvotes: 2