I have a dictionary that looks like this:
public Dictionary<string, List<EquipmentRow>> TableRows { get; set; }
EquipmentRow class:
public class EquipmentRow
{
public string Model { get; set; }
public bool New { get; set; }
}
I want to create/filter a structurally same Dictionary as the previous one which only contains a list of items in which property New is equal to true.
How to achieve that by using a Lambda Expression?
For example:
var newLocationDevices = locationDevices.Where(x => x.Value.Where()) etc.
>Solution :
You can do it simply using this code:
var newLocationDevices = locationDevices
.ToDictionary(
o => o.Key,
o => o.Value.Where(i => i.New).ToList()
);