G
Guest
Hi,
In my quest for performance, I come up with another question...
There is no DataTable.Copy() with CF and I need to do that. So I came up
with my own implementation which is as follow:
public static DataTable DataTableCopy(DataTable dtOriginal)
{
DataTable dtCopy = dtOriginal.Clone();
try
{
for (int j=0;j<dtOriginal.Rows.Count;j++)
{
dtCopy.ImportRow(dtOriginal.Rows[j]);
}
}
catch(Exception ex)
{
throw new System.Exception("Datatable copy error", ex);
}
return dtCopy;
}
I'm wondering if it is the fastest way to do it though. I use ImportRow
because I need to preserve the RowState values.
Any comment on this?
Thanks,
Sitar.
In my quest for performance, I come up with another question...
There is no DataTable.Copy() with CF and I need to do that. So I came up
with my own implementation which is as follow:
public static DataTable DataTableCopy(DataTable dtOriginal)
{
DataTable dtCopy = dtOriginal.Clone();
try
{
for (int j=0;j<dtOriginal.Rows.Count;j++)
{
dtCopy.ImportRow(dtOriginal.Rows[j]);
}
}
catch(Exception ex)
{
throw new System.Exception("Datatable copy error", ex);
}
return dtCopy;
}
I'm wondering if it is the fastest way to do it though. I use ImportRow
because I need to preserve the RowState values.
Any comment on this?
Thanks,
Sitar.