Boopathi
(Boopathi Manogar)
September 24, 2020, 3:43am
1
Hi @ppr
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.
Thanks,
Boopathi
daniel.sa
(Daniel Anthuvan)
September 24, 2020, 4:18am
2
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
Yoichi
(Yoichi)
September 24, 2020, 5:05am
3
Hi,
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
Regards,
Hi @Boopathi ,
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.
Thanks,
Shikhar
Boopathi
(Boopathi Manogar)
September 24, 2020, 5:25am
5
Hi @Yoichi
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)
Thanks,
Boopathi
Boopathi
(Boopathi Manogar)
September 24, 2020, 5:26am
6
HI @Shikhar_Tandon
Yes, but i am trying to filter data only using Linq so trying Linq queries.
Thanks,
Boopathi
Yoichi
(Yoichi)
September 24, 2020, 6:32am
7
Hi,
I just modified your xaml as the following. can you try it?
FilterLinq.xaml (10.6 KB)
Regards,
2 Likes
Boopathi
(Boopathi Manogar)
September 24, 2020, 7:24am
8
@Yoichi Thanks a lot. Got it
1 Like
system
(system)
Closed
September 27, 2020, 7:24am
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.