How to convert EnumerableRowCollection to DataTable

How to convert EnumerableRowCollection to DataTable

Hey @MariaJosephina,

Please use copyToDataTable extension method to achieve this.

@amarasto
I tried. I am not able to get this method in the list.

Hi @MariaJosephina,

Please copy your code here for clarity…

Hey @MariaJosephina,

can you share your code here?

@amarasto @manoj-vkumar
DT = dt.AsEnumerable.Select(Function(s) s(“Column1”).ToString + s(“Column2”).ToString )JoinColumn.xaml (7.3 KB)

Hey @MariaJosephina,

Please use add data row inside foreach loop.

@amarasto.
I am trying to avoid the use of for loop.
As the number of items will be more than 500, I want to avoid the iterations of 500.

Thanks

Hey @MariaJosephina,

Please help me to understand what you are trying to achieve using below statement:

DT = dt.AsEnumerable.Select(Function(s) s(“Column1”).ToString + s(“Column2”).ToString )

@amarasto
I have a data table dt with 2 columns column1 and column2

column1 column2
abc 123
def 234
ghi 345
xyz 457

I want the output as a data table with as sigle column column3 which is the concatenated value of column1 an column2
for eg:

column3
abc123
def234
ghi
xyz457

I tried to concatenate the value like : DT = dt.AsEnumerable.Select(Function(s) s(“Column1”).ToString + s(“Column2”).ToString .

But this is returning EnumerableRowCollection object.
ANd I want to convert it into a datatable without using for loop.

Thanks

Hi @MariaJosephina,

PFA, I’ve added a solution for your scenario. Check the below of your code.
I hope this will be helpful.

Thanks and Regards,
Manoj Vijayakumar.

JoinColumn.xaml (14.1 KB)

@manoj-vkumar.
Thanks for the workflow. Currently I have also done the implementation using the for loop.
But inorder to avoid the iterations, I wanted to exclude the use of for-loop and I am looking for some other solutions.

Hi @MariaJosephina,

PFA, I’ve modified something with the above code.
I hope this will be satisfy your concern.

Thanks and Regards,
Manoj Vijayakumar.

JoinColumn.xaml (8.3 KB)

@manoj-vkumar
Thanks for the quick solution.
But this ‘dt_Column.Expression’ doesnot work for column names separated by space character (eg : Container Number) This only works for ‘ContainerNumber’.

Hi @MariaJosephina,

Nope, it’ll work for that also.
PFA, and let me know your feedback. It’ll help our forum members.

Thanks and Regards,
Manoj Vijayakumar.

JoinColumn.xaml (9.1 KB)

Just a heads up that adding a single datarow to a datatable is very insignificant in terms of processing power or time. 500 rows would be done in a fraction of a second. 1 million rows would take a second or two max.

1 Like

Hi @MariaJosephina,

If you checked the above code, please post your feedback.

Let our community members to know that…

Thanks much,
Manoj Vijayakumar.

1 Like

Thanks a lot @manoj-vkumar.
It worked.

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