0

以下は私のクラス構造です

   public class ProductInfo
         Dim productName As string 
      Dim productCode As string 
      Dim Locations As List(of String)
   End Class

製品リストの取得

Dim listProd As List(of ProductInfo)= entityProvider.GetProducts();

私のコレクションには 50 個の製品が含まれており、各製品にはいくつかの場所があります。Linq を使用してこのコレクションをクエリして、個別のサブコレクションを取得するにはどうすればよいですか (すべてLocationsの製品に対してすべてですが、個別です。2 つの製品が同じ場所に表示されるため)。

.NET 3.5 CEを使用しています

前もって感謝します。

4

1 に答える 1

2

SelectManyすべての場所を取得しDistinctて区別するために使用します。

Dim distinctLocations = entityProvider.GetProducts().
    SelectMany(Function(p) p.Locations).
    Distinct()
于 2013-09-06T11:36:09.367 に答える