I have a model which contains a list and I need to remove/delete all items from the model based on the MarkedForDeletion value.
So far I've tried the following but this is not valid, I would prefer to not loop through the records using a for loop.
Models cs
public class CategoryModel
{
public string Label { get; set; }
public List<ItemModel> Items { get; set; }
}
public class ItemModel
{
public string Label { get; set; }
public bool MarkedForDeletion { get; set; )
}
Attempted Solution (not a valid statement)
CategoryModel.Items.Where(x => x.MarkedForDeletion = true).Remove;