This project has moved. For the latest updates, please go here.

System.Data.SqlClient.SqlBulkCopy Extension Methods

SqlBulkCopy.GetSqlConnection Method

A SqlBulkCopy extension method that return the SqlConnection from the SqlBulkCopy.

Syntax

SqlConnection GetSqlConnection(SqlBulkCopy @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System.Data.SqlClient;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_Data_SqlClient_SqlBulkCopy_GetSqlConnection
     {
         [TestMethod]
         public void GetSqlConnection()
         {
             // Examples
             using (var conn = new SqlConnection(My.Config.ConnectionString.UnitTest.ConnectionString))
             {
                 using (var @this = new SqlBulkCopy(conn))
                 {
                     SqlConnection value = @this.GetSqlConnection();
 
                     // Unit Test
                     Assert.AreEqual(conn, value);
                 }
             }
         }
     }
 }
                

SqlBulkCopy.GetTransaction Method

A SqlBulkCopy extension method that return the SqlTransaction from the SqlBulkCopy.

Syntax

SqlTransaction GetTransaction(SqlBulkCopy @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System.Data.SqlClient;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_Data_SqlClient_SqlBulkCopy_GetTransaction
     {
         [TestMethod]
         public void GetTransaction()
         {
             // Examples
             using (var conn = new SqlConnection(My.Config.ConnectionString.UnitTest.ConnectionString))
             {
                 conn.Open();
                 SqlTransaction trans = conn.BeginTransaction();
 
                 using (var @this = new SqlBulkCopy(conn, SqlBulkCopyOptions.Default, trans))
                 {
                     SqlTransaction value = @this.GetTransaction();
 
                     // Unit Test
                     Assert.AreEqual(trans, value);
                 }
             }
         }
     }
 }
                

Last edited Nov 23, 2013 at 7:53 PM by Jonathan_Magnan, version 1