Created
December 16, 2010 15:02
-
-
Save underwhelmed/743492 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System.Data.SqlClient | |
Imports System.Collections.Generic | |
Imports SD.LLBLGen.Pro.ORMSupportClasses | |
Public Interface ISqlBulkCopyWrapper | |
Sub WriteToServer(ByVal destTableName As String, ByVal table As DataTable, ByVal mappings As IEnumerable(Of SqlBulkCopyColumnMapping), ByRef tran As ITransaction) | |
End Interface | |
Public Class SqlBulkCopyWrapper | |
Implements ISqlBulkCopyWrapper | |
Public Sub WriteToServer(ByVal destTableName As String, ByVal table As DataTable, ByVal mappings As IEnumerable(Of SqlBulkCopyColumnMapping), ByRef tran As ITransaction) Implements ISqlBulkCopyWrapper.WriteToServer | |
Dim copy As New SqlBulkCopy(CType(tran.ConnectionToUse, SqlConnection), _ | |
SqlBulkCopyOptions.Default, _ | |
CType(tran.PhysicalTransaction, SqlTransaction)) | |
If Not mappings Is Nothing AndAlso mappings.Count > 1 Then | |
For Each map As SqlBulkCopyColumnMapping In mappings | |
copy.ColumnMappings.Add(map) | |
Next | |
End If | |
copy.DestinationTableName = destTableName | |
copy.WriteToServer(table) | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment