I have a variable amount contains value 300 and a datable with columns debit and credit.
I need to check if the amount is in the debit column which will have 300.00 and sometimes debit column will have empty values
I am able to compare with simple linq but getting error if the debit value is empty. Could you pls help in applying condition to remove empty values in debit before using linq condition and getting syntax error when trying this.
This is the linq using
It will work only if debit column is not empty. If it is empty will get error conversion from “” to double.
HI, This exception occurs if the value you’re trying to find is not available in that column.
I have used Query syntax to replicate your scenario. But it shouldn’t be any different.
With the same query, first take a count on the number of rows returned to an int32 variable before converting it into list.
Then you can have a condition to have count greater than 0 to avoid exceptions.
When the condition is satisfied, using the same query, put it into a list.
let me know if this works for you
How about the following expression?
InputDataTable.AsEnumerable.Where(Function(r) r("Debit") isnot Nothing AndAlso IsNumeric(("Debit").toString) AndAlso Double.Parse(r("Debit").ToString).Equals(Double.Parse(amount.toString))).toList
you can also use fiter datatable activity to remove the rows with empty values and then apply your linq on the output dt, this wuld work fine.
I was trying a query similar to this but it returning 0 but i have 2 values under debit - 300.00 and amount variable is 300. I have attached xaml. FilterLinq.xaml (10.6 KB)
Yes, but i am trying to filter data only using Linq so trying Linq queries.
I just modified your xaml as the following. can you try it?
FilterLinq.xaml (10.6 KB)
@Yoichi Thanks a lot. Got it
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.