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
以上是我的课程。 假设产品可以在不同的货架和不同的行中找到。 另外一排可以容纳多种产品。如何使用Linq获取列表中项目的摘要
数据将与此类似。
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)
注:
层1行1是第一搁架的第一行的名称。
无需显示括号中的项目名称。现在只是为了理解。
如何使用LINQ来实现这一点。 我正在使用VB.NET并针对CE 3.5。 C#建议也表示赞赏。提前致谢。
但按照设计,这是不可能的。 – kbvishnu