If you have a LINQ query stored as a string variable and you want to execute it on a DataTable, you can achieve this by dynamically creating and running the LINQ query using the DataTable.Select method.
Here is a sample Linq Query stored in String Variable
( From r In in_InputFile
Group By z=r("Country").ToString.Trim Into grp = Group
Let temp0 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("ABC")).Count
Let temp1 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("POR")).Count
Let temp2 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("PQR")).Count
Let temp3 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("DEF")).Count
Let temp4 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("wxy")).Count
Let temp5 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("Avr")).Count
Let temp6 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("ABc")).Count
Let temp7 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("MNP")).Count
Let temp8 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("GHI")).Count
Let temp9 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("xyz")).Count
Let temp10 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("FHI")).Count
Let temp11 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("STV")).Count
Let newRows = New Object() { grp(0)("Country").ToString,temp0.ToString,temp1.ToString,temp2.ToString,temp3.ToString,temp4.ToString,temp5.ToString,temp6.ToString,temp7.ToString,temp8.ToString,temp9.ToString,temp10.ToString,temp11.ToString, temp0+temp1+temp2+temp3+temp4+temp5+temp6+temp7+temp8+temp9+temp10+temp11}
Select dt_Output.Rows.Add(newRows)).CopyToDataTable
can you give an example on how can i use this linq query in the string and which datatable do i mentioned before AsEnumerable
( From r In in_InputFile
Group By z=r("Country").ToString.Trim Into grp = Group
Let temp0 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("ABC")).Count
Let temp1 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("POR")).Count
Let temp2 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("PQR")).Count
Let temp3 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("DEF")).Count
Let temp4 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("wxy")).Count
Let temp5 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("Avr")).Count
Let temp6 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("ABc")).Count
Let temp7 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("MNP")).Count
Let temp8 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("GHI")).Count
Let temp9 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("xyz")).Count
Let temp10 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("FHI")).Count
Let temp11 = grp.where( Function(x) x("Designation").ToString.Trim.Equals("STV")).Count
Let newRows = New Object() { grp(0)("Country").ToString,temp0.ToString,temp1.ToString,temp2.ToString,temp3.ToString,temp4.ToString,temp5.ToString,temp6.ToString,temp7.ToString,temp8.ToString,temp9.ToString,temp10.ToString,temp11.ToString, temp0+temp1+temp2+temp3+temp4+temp5+temp6+temp7+temp8+temp9+temp10+temp11}
Select dt_Output.Rows.Add(newRows)).CopyToDataTable
A DataTable.Select Method is different to a LINQ Selector Operator
We would not recommend to bring the approaches of Dynamic LINQ into the picture
When referring to your case:
We also answered in your other topic that we can have dynamics when using an intermediate Datastructure as a first step and generate from this the final target output
This can be done with Linq/Essential Activities and should not lead to a long modelling sequence