How to convert Object to datatable


#1

I have Object which would have one are more value,I would like to convert this object into a table and save it to a csv/excel sheet and use join function below using assign to a string varilable.

string.Join("’,’",Table1.AsEnumerable().[Select](Function(s) s.Field(Of String)(“Username”)).ToArray())

Can some once please help me with this on how to convert an object into a table and save it to a save ?


#2

Hi @syed_Basha,

I think you can use the below code

dt=dt.DefaultView.ToTable(false,"Username")

Regards,
Arivu


#3

I think you have misunderstood i am facing issue to convert an object to a table so i can utilize above code highlighted by me.

So is there any way i can use joins for an Object ?


#4

@arivu96 I think you have misunderstood i am facing issue to convert an object to a table so i can utilize above code highlighted by me.

So is there any way i can use joins for an Object ?


#5

Hello @syed_Basha,

Sorry bro, no time to make any workflow on this,
could you please go through below link?
http://www.fourthbottle.com/2015/02/convert-object-to-datatable-in-c.html

Thanks,
Pankaj


#6

@syed_Basha
Is your object is Ienumerable < DataRows >

If its IEnumerable of DataRows then we can convert to DataTable

Regards,
Mahesh


#7

I guys i figured it out steps below.

assign “Object to a string vairable”
Build a datatable with no rows
Add row to that data from the above string variable.
and write to CSV file.