Public Class Product
public Name As String
public ID as String
public ShelfList as List(of Shelf)
End Class
Public Class Shelf
public Name As String
public ID as String
public Row as List(of Row)
End Class
Public Class Row
public Name As String
public ID as String
End Class
以上是我的课。假设可以在不同的货架和不同的行中找到产品。此外,一排可以容纳多个产品。
数据将与此类似。
List(of Products) -> List(of Shelf) -> List(of Rows)
以下是类似的数据
Boost -> Shelf 1 -> Row 1,Row 2
Shelf 2 -> Row 2
Horlicks ->Shelf 1-> Row 1
Complain ->Shelf 2-> Row 2,Row 3
Colgate -> Shelf 2- Row 3
因此,我需要从上面的产品列表中生成摘要。(行名和每行项目数)
Shelf 1 Row 1 - 2 (Boost and horlicks)
Shelf 1 Row 2 - 1 (Boost)
Shelf 2 Row 1 - 1 (Horlicks)
Shelf 2 Row 2 - 2 (Complain and Boost)
Shelf 2 Row 3 - 1 (Colgate)
笔记 :
Shelf 1 Row 1 是第一个货架第一行的名称。
无需在括号中显示项目名称。现在只是为了理解而展示。
如何使用 LINQ 实现这一点。我正在使用 VB.NET 并以 CE 3.5 为目标。C# 建议也受到赞赏。提前致谢。