I think I am putting my question correctly :)
I am querying the database using LINQ to retrieve some data. Please find the code below.
var leadtasktype = _context.LeadTypeTaskTypes.Where(l => l.LeadTypeId == item.Value);
foreach(LeadTypeTaskType l in leadtasktype){
if (l.TaskTypeId == 21)
{
//I need to remove an item which has the tasktype id 21
}
}
As I mentioned in the comments, I need to remove items from the leadtasktype based on my if
condition. How do I do this?
This would seem very like another filter condition:
var leadtasktype = _context.LeadTypeTaskTypes
.Where(l => l.LeadTypeId == item.Value)
.Where(l => l.TaskTypeId != 21); // Exclude ID = 21.
var leadtasktype = _context.LeadTypeTaskTypes.Where(l => l.LeadTypeId == item.Value && l.LeadTypeId != 21);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With