列表包含列表包含列表
我有一个类似于以下的结构。
class A
{
string title;
List<B> bItem;
}
class B
{
int price;
List<C> cItem;
}
class C
{
int quantity;
}
List
包含大约 200,000 个“A”实例;
现在对象“A”包含“B”列表,对象“B”包含“C”列表;我也有多个 List
实例。现在我想找到列表中具有此类“B”的所有“A”以及具有此类包含 quantity > 的“C”的所有“B”。 500;
我面临的问题是指定 LINQ 的目标。
如果我使用 listA[0].listB[6].listC 那么它将我的搜索限制为仅提到的目标,但我想搜索整个对象“listA”。
感谢您的回复。由于我使用的是分层对象,因此我无法通过指定 a.bitem 或 c.quality 直接访问数据。因此,为了接近 c.quality,我必须执行 aList[index].bList[index].cList[index].quantity。据我所知,我无法直接指定 a.bList 或 c.quantity 或 a.bItem。
与 LINQ 查询一样,我们提供要查询的目标主体或基本数据容器,并通过将目标指定为“aList[index].bList[index].cList[index].quantity”来限制我的搜索容器。
我想搜索整个 aList 对象中数量的所有实例。
如果使用 LINQ to DataSet,那么我们在单个表中拥有完整的“C”对象,因此我们可以查询所有 c.quantity,无论其父级如何。如何在 LINQ to object 中做类似的事情。
谢谢你,
穆罕默德
I have a structure resembling following.
class A
{
string title;
List<B> bItem;
}
class B
{
int price;
List<C> cItem;
}
class C
{
int quantity;
}
List<A>
contains about 200,000 instances of "A";
Now Object "A" is such that it contains a list of "B" and object "B" contain a list of "C"; I have multiple instances of List<A>
as well. Now I want to find all "A"s in a List having such "B"s and all "B"s having such "C"s containing quantity > 500
;
The problem I am facing is to specify target for LINQ.
If I use listA[0].listB[6].listC
then it limits my search to only the mentioned target but I want to search for whole object "listA".
Thanx for replying. As I am using hierarchical object so I cannot directly access data by specifying a.bitem or c.quality. so to approach c.quality, I have to do aList[index].bList[index].cList[index].quantity. and according to my knowledge I cannot specify directly a.bList or c.quantity or a.bItem.
as in LINQ query, we provide a target body or basic container of data to query and by giving target as "aList[index].bList[index].cList[index].quantity" limits my search container.
I want to search for all instances of quantity in my whole aList object.
if using LINQ to DataSet then we have complete "C" object in a single table so we can query for all c.quantity regardless of their parent. how can do similer in LINQ to object.
Thank you,
Muhammad
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如前所述,您的问题不清楚,但您正在寻找可能:
换句话说,对于每个
A
检查所有 B 是否符合(B 中的所有 C)数量大于 500)。As mentioned, your question is unclear but it's possible that you're looking for:
In other words, for each
A
check that all B's conform to (all Cs within the B have quantity greater than 500).我认为这就是您想要的:
I think this is what you want: