Linq For Comparision of 2 Datatables

Hi Team,

I am trying to check 4 columns of 2 datatables and if satisfied then adding one column of a datatable into output datatable.
(From a In Sumif_DT
Join b In MB52_Data_DT
On a(“Material”).toString Equals b(“ID”).tostring And a(“Plant”).toString Equals b(“Plant”) And a(“unit”) Equals b(“unit”) And CInt(a(“unrestricted”)) GreaterThanOrEqual (CInt(b(“unrestricted”)))
Select notvalidmaterial_DT.Rows.Add ({a(“Material”)})
).copytodatatable

This query is not running it is showing Greaterthanorequal is not a member of integer. Please help team it is urgent.

@yashchoursia25 you need to give >= like this

(From a In Sumif_DT
Join b In MB52_Data_DT
On a("Material").ToString Equals b("ID").ToString And
   a("Plant").ToString Equals b("Plant") And
   a("unit").Equals(b("unit")) And
   CInt(a("unrestricted")) >= CInt(b("unrestricted"))
Select notvalidmaterial_DT.Rows.Add({a("Material")})
).CopyToDataTable

Hi,

Once try this

(From a In Sumif_DT
Join b In MB52_Data_DT
On a(“Material”).ToString Equals b(“ID”).ToString And
a(“Plant”).ToString Equals b(“Plant”) And
a(“unit”) Equals b(“unit”) And
Integer.Parse(a(“unrestricted”).ToString) >= Integer.Parse(b(“unrestricted”).ToString)
Select notvalidmaterial_DT.Rows.Add ({a(“Material”)})
).CopyToDataTable

@yashchoursia25
(From a In Sumif_DT
Join b In MB52_Data_DT
On a(“Material”).ToString Equals b(“ID”).ToString
And a(“Plant”).ToString Equals b(“Plant”)
And a(“unit”).Equals(b(“unit”))
And CInt(a(“unrestricted”)) >= CInt(b(“unrestricted”))
Select notvalidmaterial_DT.Rows.Add ({a(“Material”)})
).CopyToDataTable()

Not working Guys. It is showing Equals expected.

@yashchoursia25

(From a In Sumif_DT.AsEnumerable()
Join b In MB52_Data_DT.AsEnumerable()
On a.Field(Of String)(“Material”) Equals b.Field(Of String)(“ID”) And
a.Field(Of String)(“Plant”) Equals b.Field(Of String)(“Plant”) And
a.Field(Of String)(“unit”) Equals b.Field(Of String)(“unit”) And
Integer.Parse(a.Field(Of String)(“unrestricted”)) >= Integer.Parse(b.Field(Of String)(“unrestricted”))
Select notvalidmaterial_DT.Rows.Add({a.Field(Of String)(“Material”)})
).CopyToDataTable

Hi @yashchoursia25

Try this

(From a In Sumif_DT
Join b In MB52_Data_DT
On a("Material").ToString Equals b("ID").ToString AndAlso
   a("Plant").ToString Equals b("Plant") AndAlso
   a("unit") Equals b("unit") AndAlso
   CInt(a("unrestricted")) >= CInt(b("unrestricted"))
Select notvalidmaterial_DT.Rows.Add(a("Material").ToString())
).CopyToDataTable()

I hope it helps!!

not working guys.
Error message is as below.
image

Teams, it is showing equals expected.

@Yoichi any inputs about this query?

@yashchoursia25

(From a In Sumif_DT.AsEnumerable()
Join b In MB52_Data_DT.AsEnumerable()
On a.Field(Of String)("Material") Equals b.Field(Of String)("ID") And
   a.Field(Of String)("Plant") Equals b.Field(Of String)("Plant") And
   a.Field(Of String)("unit") = b.Field(Of String)("unit") And
   CInt(a.Field(Of Integer)("unrestricted")) >= CInt(b.Field(Of Integer)("unrestricted"))
Select notvalidmaterial_DT.Rows.Add(a.Field(Of String)("Material"))
).CopyToDataTable