Yes, you can join the tables by using
Linq[
^] and then you'll be able to compare row by row.
var resultset = (from d1 in datatable1.AsEnumerable()
join d2 in datatable2.AsEnumerable() on new {d1.Field<string>("Location"), d1.Field<string>("Item Type")} equals new {d2.Field<string>("Location"), d2.Field<string>("Item Type")}
join d3 in datatable3.AsEnumerable() on new {d1.Field<string>("Location"), d1.Field<string>("Item Type")} equals new {d2.Field<string>("Location"), d2.Field<string>("Item Type")}
select new {
Location = d1.Field<string>("Location"),
ItemType = d1.Field<string>("Item Type"),
Type = d1.Field<string>("Type"),
Cost1 = d1.Field<double>("Cost"),
Cost2 = d2.Field<double>("Cost"),
Cost3 = d3.Field<double>("Cost")
}).ToList();
foreach(var data in resultset)
{
if (data.Type == "GRN")
{
}
}
For further details, please see:
Querying DataSets (LINQ to DataSet) | Microsoft Docs[
^]
LINQ to DataSet Examples | Microsoft Docs[
^]
Creating a DataTable From a Query (LINQ to DataSet) | Microsoft Docs[
^]
101 LINQ Samples in C#[
^]