Ok so I'm a total noob with VB.NET and I so far I've read about a thousand forums and I've yet to get a straight answer.
I've read that VB treats anonymous types differently than C# (the why, beats me).
I have a DataTable, and I want to return a NEW Table with the duplicate entries (of columns 4 and 5) from the first one.
For ex:
T1 looks like this:
[COL4][COL5][COL6]...[COLN]
1 1
1 2
1 1
1 3
1 3
The Output Table should be like this:
[COL4] [COL5]
1 1
1 3
So far I've got this:
Dim duplicates = dt.AsEnumerable() _
.GroupBy(Function(r) New With { _
Key .a = r(4), _ 'Column 4 and Column 5 are the patters that I want to check
Key .b = r(5) _
}).Where(Function(gr) gr.Count() > 1)
The problem is reading the data. I can't cast to ANYTHING, I can't even read the results.
I can't read the 'duplicates' variable.
I don't care about the rest of the data columns, I don't have to have the whole DataRow as a result, I just want those two columns (4 and 5) for the items that are repeated.
Hope anyone can help me solve this.