Convert Data Row In String

Hi All,

I am getting an error for the below expression :How can I convert it to string form of the expression?
image

ExtractDataTable.AsEnumerable.Where(Function(x) x(“RATE TYPE”).ToString="One-Time Charge"And one_TimeDiscount.AsEnumerable.Select(Function(y) y(“INTERNAL ID”).ToString.Trim).ToArray.Contains(x(“INTERNAL ID”).ToString))

@marina.dutta

Can you please explain what you are trying to achieve?

is this what you want?

String.Join(",",ExtractDataTable.AsEnumerable.Where(Function(x) x("RATE TYPE").ToString="One-Time Charge"And on_TimeDiscount.AsEnumerable.Select(Function(y) y("INTERNAL ID").ToString.Trim).ToArray.Contains(x("INTERNAL ID").ToString)).First().ItemArray)

this joins all values of first filtered row with comma

cheers

@Anil_G

Basically , I want to take the sum of Rate Type =“One-Time Charge” if there is matching Internal Id of first Data Table and Second Data Table. If the Internal Ids of first and Second Data Table match , then select the Rate Type = “One-Time Charge” . If multiple matches rae found , then take the sum.

ExtractDataTable.AsEnumerable.Where(Function(x) one_TimeDiscount.AsEnumerable.Select(Function(y) y(“INTERNAL ID”).ToString.Trim).ToArray.Contains(x(“INTERNAL ID”).ToString.Trim)).Sum(Function(x) (x(“RATE TYPE”).ToString=“One-Time Charge”)))

@marina.dutta

I see a lot of difference between initial ask and the current one and also its not very clear…

as per my understanding this is what you need I believe,if not please explain a little

ExtractDataTable.AsEnumerable.Where(Function(x) x("RATE TYPE").ToString="One-Time Charge"And one_TimeDiscount.AsEnumerable.Select(Function(y) y("INTERNAL ID").ToString.Trim).ToArray.Contains(x("INTERNAL ID").ToString)).Sum(function(x) CDBL(x("SumColumnYou need").ToString))

this gives you the sum of required sum column you need when rete type is one-time charge and internal_id is matched with the internal id in one_timedisccount

cheers

@Anil_G

Actually , I was trying different expressions but getting error .However the ask is same.

If Rate TYPE = “One Time Charge” and Internal Ids of Two Data Table Matches , then it should take the Sum Of Rate Column

@marina.dutta

the above given expression is same…please try it out

only assumption is we will find a match always…if you are not sure then first before sum use a .count>0 and if yes then do .sum

cheers

@Anil_G

Here , I am storing the sum of Rate in string variable. hence I want to convert the expression into string. so getting error.

image

@marina.dutta

add .tostring at the end…sum is generally in double

cheers

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