i've not tried this, so i can't say for sure that it'll be faster, but it seems to me that you'd get much better speed using something like the following:

dim l_destinationtable as datatable
' this creates a copy of the structure and content
l_destinationtable = sourcetable.copy()

for each l_column as datacolumn in l_destinationtable.columns
    dim l_columnmap = omappinginfo.firstordefault( _
        function (c) c.sourcefieldname = l_column.columnname )
    if l_columnmap isnot nothing then
        ' rename the column if it is mapped
        l_column.columnname = l_columnmap.destinationfieldname
        ' drop the column if it is not mapped
        l_destinationtable.columns.remove( l_column )
    end if

note: this method will fail if an unmapped column is part of a relationship or another column's expression depends on this column. also, if you are swapping the name of two columns (for example, a will be named b and b will be named a) then you will get an exception as two columns may not have the same name at the same time.

Related Query

More Query from same tag