I am trying group by column1 and then get the first item from Column2 from each group. Any input on what data type group by is creating and how to see individual entry’s.
my input
Column1(String) Coulumn2(Int32)
text 1
love 0
text 4
love 2
one 8
Desired Output
Column1(String) Coulumn2(Int32)
text 1
love 0
one 8
my output
[Column1,Column2
text,System.Data.DataRow
love,System.Data.DataRow
one,
]
code so far
(From d In dt_t2.asEnumerable()
Group d By
ID = d(0)
Into grp=Group
Let ra = New Object(){ID,grp(1)}
Select dt_t.Rows.Add(ra)).CopyToDataTable
@David_Ellis
Welcome to the forum
You was close to the solution just add also which col to catch from first group member row
(From d In dt_t2.asEnumerable()
Group d By ID = d(0) Into grp=Group
Let ra = New Object(){ID,grp.First()("Column2")}
Select dt_t.Rows.Add(ra)).CopyToDataTable
we used Column2 as we do feel Coulumn2 was a typo
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.