Код: Выделить всё
public class location
{
public Dictionary Example{ get; set; }
}
public class location
{
public int Id { get; set; }
public string Name{ get; set; }
}
i would like to filter dictionary where Id = 3
Код: Выделить всё
var filteredLocations = locations.Select(location =>
{
var filteredDict = location
.Example
.ToDictionary(
outerKey => outerKey.Key,
outerValue => outerValue.Value
.ToDictionary(
middleKey => middleKey.Key,
middleValue => middleValue.Value
.Where(innerEntry => innerEntry.Value.id== 3)
.ToDictionary(innerKey => innerKey.Key, innerValue => innerValue.Value)
)
);
location.Example= filteredDict;
return new Location(location);
})
.ToList();
Подробнее здесь: https://stackoverflow.com/questions/787 ... in-c-sharp
Мобильная версия