title: How can i copy data table records of different field name based on mapping list evaluating condition on source data table?
body: <p>I have a Source Data table of type System.Data.DataTable from which i have to generate Destination Data Table of mapped column(Consider same SqlDBType for mapped columns.)</p>
  
  <p>I have a list of MappingInfo class in which each Source Datatable Column mapped with New Column Name which will be in destination data table.</p>
  
  <pre><code>Public Class MappingInfo
  
      Public Property SourceFieldName As String
      Public Property DestinationFieldName As String
  
  End Class
  </code></pre>
  
  <p>I have to evaluate a condition in source datatable to allow row data copy in destination table.</p>
  
  <p>I did this using following code snippet:</p>
  
  <pre><code>''Prepare destination table.
  
  For Each oMapping In oMappingInfo  
  
              DestinationDataTable.Columns.Add( _
                  New DataColumn(oMapping.DestinationFieldName))
          Next
  
          For Each oRow In SourceDataTable.Rows   ''Copy data.
              If oRow("IsActive") Then
                  oDataRow = DestinationDataTable.NewRow
                  For Each oMapping In oMappingInfo
                      oDataRow(oMapping.DestinationFieldName) = _
                          oRow(oMapping.SourceFieldName)
                  Next
                  DestinationDataTable.Rows.Add(oDataRow)
              End If
          Next
  </code></pre>
  
  <p>The main drawback is that here i have minimum 40k records in source datatable and data is not possible to fetch from database as all changes with data committed only when user save his work. The generated destination table is been assigned as data source to grid control  and to report for preview. </p>
  
  <p>How can i achieve this efficiently using Linq or do anyone please suggest me best way to achieve this requirement.</p>