c# - How to get what's in datatable where exist in another datatable by LINQ -
if have 2 datatables :
dt1 emp_num name status 1 aa 1 2 bb 1 3 cc 2
dt2 emp_num name dep_code 1 aa 536 2 bb 782 4 yuw 21 5 rr 892
how in dt1
, must exist in dt2
, put result in datatable
the result :
emp_num name status 1 aa 1 2 bb 1
you use linq
var result = (from in dt1.rows join b in dt2.rows on dt1.rows["emp_num"]==dt2.rows["emp_num"] select a).copytodatatable<datarow>();
Comments
Post a Comment