var dept_list = (from map in DtMapGuestDepartment.AsEnumerable()
where map.Field<Nullable<long>>("GUEST_ID") == DRowGuestPI.Field<Nullable<long>>("PK_GUEST_ID")
join
dept in DtDepartment.AsEnumerable()
on map.Field<Nullable<long>>("DEPARTMENT_ID") equals dept.Field<Nullable<long>>("DEPARTMENT_ID")
select new
{
dept_id=dept.Field<long>("DEPARTMENT_ID")
,dept_name=dept.Field<long>("DEPARTMENT_NAME")
}).Distinct();
DataTable dt = new DataTable();
dt.Columns.Add("DEPARTMENT_ID");
dt.Columns.Add("DEPARTMENT_NAME");
foreach (long? dept_ in dept_list)
{
dt.Rows.Add(dept_[0], dept_[1]);
}
EDIT
In the previous question asked by me.
I got an answer like this for single value. What is the difference between the two ?
foreach (long? dept in dept_list) {
dt.Rows.Add(dept);
}