How to use abs and cdbl function using LINQ

Description:

  1. I have one datatable named Report_DT, this datatable have one column called “Trade Amount”
    2.This datatable have one column called “aa[ Trade Amount ]”, the value have positive and negative numbers(EG:-12.34, 45.67)
    3.I want to use LINQ
    4.My Linq is: Report_DT.Select(“(abs(Cdbl([aa[ Trade Amount \]]))='Cdbl(”+OracleItem(“Trans. Debits”).ToString+“)’ or abs(Cdbl([aa[ Trade Amount \]]))='Cdbl(”+OracleItem(“Trans. Credits”).ToString+“)')”)
    5.System prompt Error “Assign: The expression contains undefined function call Cdbl().”
    Please help to solve this issue, or tell me how to use abs and cdbl function using LINQ

image

hey!
Math.Abs - Converts negative value to positive.Try to modify with this

I try and thrown error as below:

image

can u elaborate what exaclty you are trying to do using this linq?

1 Like

Hi,

The above expression is not LINQ but DataTable.Select method.
Can you share input and expected output as file? it’s no problem if dummy data.

Regards,

Search the amount equal from two excel.

image

Amount_new.xlsx (8.5 KB)
Amount.xlsx (7.9 KB)

Hi,

Can you also share expected output?

Regards,

just need datatable select method can work, I do not know how to use abs and cdlb before the = symbol

HI,

DataTable.Select doesn’t support Cdbl. Please check the following document in details

https://www.csharp-examples.net/dataview-rowfilter/

If you need to filter rows using LINQ, Enumerable.Where method works and it supports any .net function such as CDbl and Math.Abs etc. For example. as the following.

dtA = dtA.AsEnumerable.Where(Function(r1) dtB.AsEnumerable.Any(function(r2) Math.Abs(CDbl(r1("Col1")))=Math.Abs(CDbl(r2("Col1"))))).CopyToDataTable

Regards,

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