Hi All,
I need to change the one value in particular column using LINQ query
Input
22-
34-
35-
26-
46-
Output
-22
-34
-35
-26
-46
The output should be an Data Table type. Help me on this
Regards,
Kaviyarasu N
Hi All,
I need to change the one value in particular column using LINQ query
Input
22-
34-
35-
26-
46-
Output
-22
-34
-35
-26
-46
The output should be an Data Table type. Help me on this
Regards,
Kaviyarasu N
@Kaviyarasu_N
DT.AsEnumerable.Tolist.Foreach(Sub(r) r(“columnname”)=“-”+r(“columnname”).tostring.replace(“-”,“”)).Copytodatatable
How about this LINQ expression
DtBuild.AsEnumerable.Select(Function(r) DtBuild.Clone.LoadDataRow({System.Text.RegularExpressions.Regex.Replace("-"+r("Column 1").ToString,"\W$",""),r("Column 2"),r("Column 3")},False)).CopyToDataTable
Check out the XAML file
Find&Replace.xaml (9.1 KB)
Regards
Gokul
I am getting an error
You can use an invoke code activity for the same
dtout.AsEnumerable.ToList.ForEach(Sub(row)
row("ColumnName")="-"+row("ColumnName").ToString.Replace("-","")
End Sub
)
Thanks
Try below @Kaviyarasu_N
Use Invoke Code
Edit Arguments, Datatable should be I/O direction
dtSample.AsEnumerable.Where(Function(row) row(“Column1”).ToString.EndsWith(“-”)).ToList().ForEach(Sub(row) row(“Column1”) = "-"+row("Column1").Tostring.split("-"c)(0))
Above expression will take the values which ends with - and then manipulate
Hope this may help you
Thanks,
Srini
Use this code inside invoke code activity and see
Hi All,
Thanks for your answers. I want the code for this. Please check in below
Input
22-
34
-35
26-
-46
Output
-22
-34
-35
-26
-46
Regards
kaviyarasu N
Checkout this expression
(From D In Dt1.AsEnumerable
Let i= System.Text.RegularExpressions.Regex.Replace(d(0).ToString,"\d+","").ToString+System.Text.RegularExpressions.Regex.Match(d(0).ToString,"\d+").ToString
Select Dt2.Rows.Add(i)).CopyToDataTable
Regards
Sudharsan
Have you checked this XAML file? @Kaviyarasu_N
Works with the input you shared too @Kaviyarasu_N
Regards
Sudharsan
HI @Sudharsan_Ka @Gokul001 @Srini84
I want code for this. The output must be as datatable. Please share screenshots if possible.
Note: Use assign activity for LINQ query
Thanks!!!
How about this LINQ expression
DtBuild.AsEnumerable.Select(Function(r) DtBuild.Clone.LoadDataRow({"-"+System.Text.RegularExpressions.Regex.Replace(r("Column 1").ToString,"\W","")},False)).CopyToDataTable
Check out the XAML file
Find&Replace.xaml (9.0 KB)
Regards
Gokul
Thank you all for quick responses
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.