Linq query for multipy

i need to multipy entire column
LinqError 2
getting error

Hi @sathya_auto

Try this

Assign activity: multipliedData =
    (From row In dtData.AsEnumerable()
     Let originalValue = row.Field(Of Double)("ColumnName") // Replace "ColumnName" with the actual column name
     Let multipliedValue = originalValue * 3
     Select row.ItemArray.CopyToDataTable().Rows(0))

@sathya_auto

Assign activity:
resultDataTable = (From row In dataTable.AsEnumerable()
Let originalValue = row.Field(Of Double)(“ValueColumn”)
Let multipliedValue = originalValue * 3
Select row.Field(Of Double)(“ValueColumn”) = multipliedValue).CopyToDataTable()

i need in array thanks i for replaying

data_arr= dt1.Select(Function(row) (CDbl(row(column1))*CDbl(row(column2))).ToString).ToArray()

Try this
hope it helps

@sathya_auto

Try this


(
    From row In DTr.AsEnumerable()
    Let originalAmount = CInt(row("Column1"))
    Let multipliedAmount = originalAmount * 3
    Select multipliedAmount
).ToArray()

hi @sathya_auto
use this you will the required output

dt.AsEnumerable.Select(Function(a) CDbl(a(0).ToString)*3).ToArray

cheers

@sathya_auto

Try this it is working as expected

unfortunately, it was not mentioned which error.

For the general rule:
When Datatable us involved within a LINQ do not ommit the appending AsEnumerable

YourDataTableVar.AsEnumerable()

When the error is about parsing issues:

  • handle local formats with Specific CultureInfos
  • handle empty/null/non parseable strings by filtering out or default value

@sathya_auto

outputArray = (From row In inputDataTable.AsEnumerable()
Select Convert.ToInt32(row(“ColumnName”)) * 3).ToArray()

Thankyou guys for your help

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