init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
59
Sda.DataProvider/Wrappers/MSSQL/MSSQLBulkAdapter.cs
Normal file
59
Sda.DataProvider/Wrappers/MSSQL/MSSQLBulkAdapter.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace SDA.DataProvider.MSSQLWrappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Microsoft SQL Server alapú bulk insert implementáció.
|
||||
/// </summary>
|
||||
public class MSSQLBulkAdapter : SDABulkAdapter
|
||||
{
|
||||
private readonly SqlBulkCopy bulkCopy;
|
||||
|
||||
/// <summary>
|
||||
/// Létrehoz egy Microsoft SQL Server specifikus bulk adapter példányt.
|
||||
/// </summary>
|
||||
/// <param name="bulkCopy">Egy SQL Server SqlBulkCopy példány, a
|
||||
/// tényleges bulk implementáció.</param>
|
||||
/// <exception cref="ArgumentNullException">Ha a kapott paraméter null.
|
||||
/// </exception>
|
||||
internal MSSQLBulkAdapter([NotNull] SqlBulkCopy bulkCopy)
|
||||
{
|
||||
if (bulkCopy == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(bulkCopy));
|
||||
}
|
||||
this.bulkCopy = bulkCopy;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void BulkInsert(DataTable source)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(source.TableName))
|
||||
{
|
||||
throw new ArgumentException("TableName property must be set to the target table name", nameof(source));
|
||||
}
|
||||
|
||||
if (source.Columns.Count == 0)
|
||||
{
|
||||
throw new ArgumentException("should contain at least 1 column to bulk insert", nameof(source));
|
||||
}
|
||||
|
||||
if (source.Rows.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bulkCopy.DestinationTableName = source.TableName;
|
||||
bulkCopy.WriteToServer(source);
|
||||
|
||||
//bulkCopy.NotifyAfter = 1000;
|
||||
//bulkCopy.SqlRowsCopied += (sender, args) =>
|
||||
//{
|
||||
|
||||
//};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue