0

enter image description here

Hi
I want to group the above list of stores in this case. The above is a List(of Stores) and I want create a new list of stores where they are all grouped by FromStore and ToStore.

Example:

Dim Test As List(Of Stores) = MyTStores.GroupBy(Function(x) x.ToStore).[Select](Function(grp) grp.First()).ToList()

This example only group by one columns and not two.

NetMage
  • 26,163
  • 3
  • 34
  • 55
Etienne
  • 179
  • 3
  • 12
  • Are you looking as mentioned at https://stackoverflow.com/questions/5231845/c-sharp-linq-group-by-on-multiple-columns – JyothiJ Jun 01 '18 at 10:43

1 Answers1

0
.GroupBy(Function(X) New With {X.FromStore, X.ToStore})

or just this, if you do not care about the key in next processing:

.GroupBy(Function(X) X.FromStore & "-" & X.ToStore)
PavlinII
  • 1,061
  • 1
  • 7
  • 12