Creating a dictionary from another dictionary using LINQ

后端 未结 3 2088
自闭症患者
自闭症患者 2020-12-29 04:59

I have a dictionary of the type:

IDictionary> my_dictionary

bar class looks like this:

cl         


        
3条回答
  •  孤城傲影
    2020-12-29 05:33

    Something like this?

    my_dictionary
        .Where(p=> p.Value.Any(x => x.IsValid))
        .ToDictionary( p=> p.Key,
                       p=> p.Value.Where (x => x.IsValid));
    

    That will only include items where at least one of the values IsValid.

提交回复
热议问题