Group and count with linq vb.net
I have a datatable. I would like to list double entries. This I would do with a simple sql query like:
SELECT artnr, COUNT(artnr) AS cnt FROM table GROUP BY artnr HAVING COUNT(artnr)>1
How does it look like with linq?
Every time I need to work with linq I am always stuck with it. I really don't like it.
Thank.
+3
source to share
2 answers
Not sure what your table looks like, but try it. Also I am sure there are many stack answers that illustrate grouping in VB. This may be a duplicate question.
Dim artnrGroups = From a In table _
Group a By Key = a.artnr Into Group _
Where Group.Count() > 1
Select artnr = Key, numbersCount = Group.Count()
+5
source to share