如何获得过滤后的列表?

How to get a filtered List?

场景是这样的。我有下一个 class:

class A
{ 
    string  attribute1; 
    string  attribute2;
    List<B> attribute3;
}

class B 
{
    string attribute1;
}

我的程序运行:

list<Class A>    myList

我想得到,使用linq过滤,一个特定的列表Class A

因此,据我所知,我正在通过以下方式获取列表或列表:

myList.SelectMany(o => o.attribute3.Where(p => p.attribute1 == "test")).ToList()

myList.SelectMany(o => o.attribute3.Select(p => p.attribute1 == "test")).ToList()

有线索吗?谢谢朋友们。

就运行:

myList.Where(o => o.attribute3.Any(p => p.attribute1 == "test")).ToList()