【发布时间】:2018-05-24 15:37:34
【问题描述】:
这就是场景。我有下一节课:
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()
有什么线索吗?谢谢小伙伴们。
【问题讨论】:
-
你想得到什么结果?
-
@HesamFaridmehr。感谢您的答复。我想得到一个过滤列表类。
-
你想获取所有A中任何B都有测试值的A类吗?
-
我想得到一个所有 A 类的普通列表,它的属性 3 中有一个值 == "test"(即 B 类列表)。 @HesamFaridmehr
标签: c# asp.net linq entity-framework-6 linq-to-entities