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