Reputation: 5157
I joined two datatables & trying to get the results in the array.
dt
ID A B C
1 ab t j
2 cd h k
3 ds f g
ndt
CID E F G
1 g y gg
2 ff hg vcb
3 df vb b
Code
var query = from r0w1 in dt.AsEnumerable()
join r0w2 in ndt.AsEnumerable()
on r0w1.Field<string>("ID") equals r0w2.Field<string>("CID")
select r0w2.ItemArray.Concat(r0w1.ItemArray).ToArray();
What I want here is no to select the column CID
from above result since both the columns ID
& CID
are same. How can I avoid it ?
Upvotes: 0
Views: 320
Reputation: 34244
Assuming that CID
always goes first in your row, you can utilize LINQ Skip
to skip the first item:
var query = from r0w1 in dt.AsEnumerable()
join r0w2 in ndt.AsEnumerable()
on r0w1.Field<string>("ID") equals r0w2.Field<string>("CID")
select r0w2.ItemArray.Skip(1).Concat(r0w1.ItemArray).ToArray();
Upvotes: 1