Linq error showing equals expected

Hi Team,

I am using LINQ query, but error is showing as Equals Expected.
(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

Please help.

Hi @yash.choursia

Try this:

(From a In Sumif_DT.AsEnumerable()
Join b In MB52_Data_DT.AsEnumerable()
On a.Field(Of String)("Material") = b.Field(Of String)("ID") And
a.Field(Of String)("Plant") = b.Field(Of String)("Plant") And
a.Field(Of String)("unit") = 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

Try retype the double quotes in your code.

(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") AndAlso
   a.Field(Of String)("Plant") Equals b.Field(Of String)("Plant") AndAlso
   a.Field(Of String)("unit") Equals b.Field(Of String)("unit") AndAlso
   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


Again Same error

@yash.choursia

Retype the double quotes in your code.

@yash.choursia Try retyping the quotes in the query


This is the error

Not working @supriya117 , i tried retyping the entire code but again it is showing the same thing a equals expected.

Here’s the corrected LINQ query:

(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.TryParse(a.Field(Of String)("unrestricted"), unrestrictedA) _
     And Integer.TryParse(b.Field(Of String)("unrestricted"), unrestrictedB) _
     Where unrestrictedA >= unrestrictedB
 Select notvalidmaterial_DT.Rows.Add({a.Field(Of String)("Material")})
).CopyToDataTable

In this corrected query, the && operator is used to combine the conditions for matching the Material, Plant, and unit fields, and Integer.TryParse is used to safely parse the integer values from the fields unrestricted of Sumif_DT and MB52_Data_DT. The records will be filtered based on the condition unrestrictedA >= unrestrictedB.

Please note that you should replace unrestrictedA and unrestrictedB with appropriate variable names (e.g., unrestrictedA could be aUnrestricted and unrestrictedB could be bUnrestricted) to store the parsed integer values.

Hi @ByteBreaker, The below error is showing.

(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.TryParse(a.Field(Of String)(“unrestricted”), unrestrictedA) Equals Integer.TryParse(b.Field(Of String)(“unrestricted”), unrestrictedB)
Where unrestrictedA >= unrestrictedB
Select notvalidmaterial_DT.Rows.Add({a.Field(Of String)(“Material”)})
).CopyToDataTable

Try This Code

it is showing unrestrictedA and unrestrictedB is not declared in the current scope or not declared.

(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”)
Where CInt(a.Field(Of String)(“unrestricted”))>= CInt(b.Field(Of String)(“unrestricted”))
Select notvalidmaterial_DT.Rows.Add({a.Field(Of String)(“Material”)})
).CopyToDataTable

Thanks, @Quenton_Wayne_Rebello .

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.