0

I am writing a LINQ query to get the queues of an agent and then removing rows that match a specific criteria but the web page displays the entire list.

var agentQueues = _context.AgentQueues.Where(e => e.AgentId == Request.AgentId)
                                .OrderByDescending(e => e.ScheduleTime)
                                .ThenBy(e => e.AgentQueueId)
                                .ToList();

agentQueues.RemoveAll(e => !e.Status.Equals("Waiting") && !e.Status.Equals("Running") && !e.Deleted==false);

Even though I am writing RemoveAll, the query still displays rows that contain Statuses other than 'Running' and 'Waiting'. It would be great if anyone could point me to the right direction here.

1 Answer 1

2

Change your query to this, use || instead of && for status

    agentQueues.RemoveAll((e => !e.Status.Equals("Waiting") || 
!e.Status.Equals("Running")) && !e.Deleted==false);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.