LInq Query through Error

Hello Team,

I am using linq query to fatch rowIndex based on two columns but it’s troughing error this


This linq I am using.

GlobalVariables.GLReportDT.AsEnumerable()
.Where(r => r.Field(“Control”) == “J-421508” && r.Field(“Debit”) == 0.00)
.FirstOrDefault()

Hi @pawanrajpurohit

I think you are developing your flow in C#. If yes, try the below syntax once:

FindDataRow = GlobalVariables.GLReportDT.AsEnumerable().Where(r => r.Field<string>("Control") == "J-421508" && r.Field<decimal>("Debit") == 0.00m).Select(r => r.Field<string>("YourDesiredColumnName")).FirstOrDefault()

Hope it helps!!

Same Error No difference

@pawanrajpurohit

go to imports panel and try to import the library mentioned in error and check

Also what you have written would not give you a row index but would give you a datarow

cheers

There does not have any library called ReaderWritter.


Yes, You are right I am getting row. After Get row I will get index using indexof function of datatable.

@pawanrajpurohit

Can you please attach a sample file here…or specify what version and compatibiltiy and code type youa re on?

I hoep it is windows C#…do confirm the same

cheers

Yes, I am using window C#. System.Activites I am using 24.3.1 version

Same project I am using another linq and it’s working Like this example

ExtractDataTableForManyToOneDT.AsEnumerable()
.Where(row => row.Field(“Column-6”).ToLower() == “unchecked”)
.Select(row => Convert.ToDouble(row.Field(“Column-4”)))
.ToList()

@pawanrajpurohit

please try this

dt.AsEnumerable().FirstOrDefault(r => r["Control"].ToString() == "J-421508" && double.Parse(r["Debit"].ToString()) == 0.00)

cheers

@Anil_G Bro I tried your solution it’s through same error.

@pawanrajpurohit

Can you try removing the assign or try the same in a different sequence

cheers

I tried in new workflow file of same project but it’s through same error.

@pawanrajpurohit

Can you try changing the system package version …then it would automatically ask to import and get resolved

cheers

@pawanrajpurohit

or open xaml in notepad and add this line
<AssemblyReference>System.Xml.ReaderWriter</AssemblyReference>

cheers

Which xaml I need to open

I added but through same error.

Hi @pawanrajpurohit,

Try to add below mentioned package from the manage packages and then check if the error resolved or not.

Same issue. I installed but it does not work for me.

@pawanrajpurohit,

Try upgrading all the packages of the project to latest version. If you have tried this, give it a try to below solution.

Use assign activity and copy the Global variable Datatable to local Datatable variable and then use LINQ on local variable.

dtLocalVariable = GlobalVariables.GLReportDT.Copy
dtLocalVariable.AsEnumerable()
.Where(r => r.Field(“Control”) == “J-421508” && r.Field(“Debit”) == 0.00)
.FirstOrDefault()

Thanks,
Ashok :slight_smile:

I tried this is also not working