Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Add DataTable support to SqlBulkCopy. #16884

Merged
merged 1 commit into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/Microsoft.Private.PackageBaseline/packageIndex.json
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@
"4.0.0.0": "4.1.0",
"4.1.0.0": "4.1.0",
"4.1.1.0": "4.3.0",
"4.1.2.0": "4.4.0"
"4.2.0.0": "4.4.0"
}
},
"System.Data.SqlXml": {
Expand Down
2 changes: 1 addition & 1 deletion src/System.Data.SqlClient/dir.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
</PropertyGroup>
</Project>
57 changes: 57 additions & 0 deletions src/System.Data.SqlClient/ref/System.Data.SqlClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,20 @@ public event System.Data.SqlClient.SqlRowsCopiedEventHandler SqlRowsCopied { add
public void Close() { }
void System.IDisposable.Dispose() { }
public void WriteToServer(System.Data.Common.DbDataReader reader) { }
public void WriteToServer(System.Data.IDataReader reader) { }
public void WriteToServer(System.Data.DataTable table) { }
public void WriteToServer(System.Data.DataTable table, System.Data.DataRowState rowState) { }
public void WriteToServer(System.Data.DataRow[] rows) { }
public System.Threading.Tasks.Task WriteToServerAsync(System.Data.DataRow[] rows) { throw null; }
public System.Threading.Tasks.Task WriteToServerAsync(System.Data.DataRow[] rows, System.Threading.CancellationToken cancellationToken) { throw null; }
public System.Threading.Tasks.Task WriteToServerAsync(System.Data.IDataReader reader) { throw null; }
public System.Threading.Tasks.Task WriteToServerAsync(System.Data.IDataReader reader, System.Threading.CancellationToken cancellationToken) { throw null; }
public System.Threading.Tasks.Task WriteToServerAsync(System.Data.Common.DbDataReader reader) { throw null; }
public System.Threading.Tasks.Task WriteToServerAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken cancellationToken) { throw null; }
public System.Threading.Tasks.Task WriteToServerAsync(System.Data.DataTable table) { throw null; }
public System.Threading.Tasks.Task WriteToServerAsync(System.Data.DataTable table, System.Threading.CancellationToken cancellationToken) { throw null; }
public System.Threading.Tasks.Task WriteToServerAsync(System.Data.DataTable table, System.Data.DataRowState rowState) { throw null; }
public System.Threading.Tasks.Task WriteToServerAsync(System.Data.DataTable table, System.Data.DataRowState rowState, System.Threading.CancellationToken cancellationToken) { throw null; }
}
public sealed partial class SqlBulkCopyColumnMapping
{
Expand Down Expand Up @@ -372,6 +384,44 @@ public override void Clear() { }
public override bool ShouldSerialize(string keyword) { throw null; }
public override bool TryGetValue(string keyword, out object value) { throw null; }
}
public sealed partial class SqlDataAdapter : System.Data.Common.DbDataAdapter, System.Data.IDbDataAdapter, System.ICloneable
{
public SqlDataAdapter() { }
public SqlDataAdapter(SqlCommand selectCommand) { }
public SqlDataAdapter(string selectCommandText, string selectConnectionString) { }
public SqlDataAdapter(string selectCommandText, SqlConnection selectConnection) { }
new public SqlCommand DeleteCommand { get { throw null; } set { } }
new public SqlCommand InsertCommand { get { throw null; } set { } }
new public SqlCommand SelectCommand { get { throw null; } set { } }
System.Data.IDbCommand System.Data.IDbDataAdapter.DeleteCommand { get { throw null; } set { } }
System.Data.IDbCommand System.Data.IDbDataAdapter.InsertCommand { get { throw null; } set { } }
System.Data.IDbCommand System.Data.IDbDataAdapter.SelectCommand { get { throw null; } set { } }
System.Data.IDbCommand System.Data.IDbDataAdapter.UpdateCommand { get { throw null; } set { } }
override public int UpdateBatchSize { get { throw null; } set { } }
new public SqlCommand UpdateCommand { get { throw null; } set { } }
public event SqlRowUpdatedEventHandler RowUpdated { add { } remove { } }
public event SqlRowUpdatingEventHandler RowUpdating { add { } remove { } }
protected override void OnRowUpdated(System.Data.Common.RowUpdatedEventArgs value) { }
protected override void OnRowUpdating(System.Data.Common.RowUpdatingEventArgs value) { }
object System.ICloneable.Clone() { throw null; }
}
public sealed partial class SqlRowUpdatedEventArgs : System.Data.Common.RowUpdatedEventArgs
{
public SqlRowUpdatedEventArgs(DataRow row, IDbCommand command, StatementType statementType, System.Data.Common.DataTableMapping tableMapping)
: base(row, command, statementType, tableMapping) { }

new public SqlCommand Command { get { throw null; } }
}
public delegate void SqlRowUpdatedEventHandler(object sender, SqlRowUpdatedEventArgs e);
public sealed partial class SqlRowUpdatingEventArgs : System.Data.Common.RowUpdatingEventArgs
{
public SqlRowUpdatingEventArgs(DataRow row, IDbCommand command, StatementType statementType, System.Data.Common.DataTableMapping tableMapping)
: base(row, command, statementType, tableMapping) { }

new public SqlCommand Command { get { throw null; } set { } }
protected override System.Data.IDbCommand BaseCommand { get { throw null; } set { } }
}
public delegate void SqlRowUpdatingEventHandler(object sender, SqlRowUpdatingEventArgs e);
public partial class SqlDataReader : System.Data.Common.DbDataReader, System.IDisposable
{
internal SqlDataReader() { }
Expand Down Expand Up @@ -573,3 +623,10 @@ public void Rollback(string transactionName) { }
public void Save(string savePointName) { }
}
}
namespace System.Data
{
public sealed partial class OperationAbortedException : System.SystemException
{
internal OperationAbortedException() { }
}
}
6 changes: 6 additions & 0 deletions src/System.Data.SqlClient/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
<data name="ADP_InvalidEnumerationValue" xml:space="preserve">
<value>The {0} enumeration value, {1}, is invalid.</value>
</data>
<data name="ADP_NotSupportedEnumerationValue" xml:space="preserve">
<value>The {0} enumeration value, {1}, is not supported by the {2} method.</value>
</data>
<data name="ADP_InvalidOffsetValue" xml:space="preserve">
<value>Invalid parameter Offset value '{0}'. The value must be greater than or equal to 0.</value>
</data>
Expand Down Expand Up @@ -265,6 +268,9 @@
<data name="ADP_ParameterValueOutOfRange" xml:space="preserve">
<value>Parameter value '{0}' is out of range.</value>
</data>
<data name="ADP_BadParameterName" xml:space="preserve">
<value>Specified parameter name '{0}' is not valid.</value>
</data>
<data name="ADP_InvalidSizeValue" xml:space="preserve">
<value>Invalid parameter Size value '{0}'. The value must be greater than or equal to 0.</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions src/System.Data.SqlClient/src/System.Data.SqlClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<Compile Include="System\Data\SqlClient\SqlConnectionString.cs" />
<Compile Include="System\Data\SqlClient\SqlConnectionStringBuilder.cs" />
<Compile Include="System\Data\SqlClient\SqlConnectionTimeoutErrorInternal.cs" />
<Compile Include="System\Data\SqlClient\SqlDataAdapter.cs" />
<Compile Include="System\Data\SqlClient\SqlDataReader.cs" />
<Compile Include="System\Data\SqlClient\SqlEnums.cs" />
<Compile Include="System\Data\SqlClient\SqlError.cs" />
Expand All @@ -102,6 +103,10 @@
<Compile Include="System\Data\SqlClient\SqlParameterCollectionHelper.cs" />
<Compile Include="System\Data\SqlClient\SqlParameterHelper.cs" />
<Compile Include="System\Data\SqlClient\SqlReferenceCollection.cs" />
<Compile Include="System\Data\SqlClient\SqlRowUpdatedEvent.cs" />
<Compile Include="System\Data\SqlClient\SqlRowUpdatedEventHandler.cs" />
<Compile Include="System\Data\SqlClient\SqlRowUpdatingEvent.cs" />
<Compile Include="System\Data\SqlClient\SqlRowUpdatingEventHandler.cs" />
<Compile Include="System\Data\SqlClient\SqlSequentialStream.cs" />
<Compile Include="System\Data\SqlClient\SqlSequentialTextReader.cs" />
<Compile Include="System\Data\SqlClient\SqlStatistics.cs" />
Expand Down Expand Up @@ -326,6 +331,7 @@
<Reference Include="System.Collections" />
<Reference Include="System.Collections.Concurrent" />
<Reference Include="System.ComponentModel.Primitives" />
<Reference Include="System.ComponentModel.TypeConverter" />
<Reference Include="System.Data.Common" />
<Reference Include="System.Diagnostics.Debug" />
<Reference Include="System.Diagnostics.DiagnosticSource" />
Expand Down
46 changes: 38 additions & 8 deletions src/System.Data.SqlClient/src/System/Data/Common/AdapterUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ internal static string GetString(string format, params object[] args)
}
}


namespace System.Data.Common
{
internal static class ADP
Expand All @@ -41,7 +40,6 @@ internal static class ADP
// The exception is then returned to the caller, so that the caller may then throw from its
// location so that the catcher of the exception will have the appropriate call stack.
// This class is used so that there will be compile time checking of error messages.

internal static Exception ExceptionWithStackTrace(Exception e)
{
try
Expand Down Expand Up @@ -249,6 +247,12 @@ internal static ArgumentException InvalidMultipartNameToManyParts(string propert
return e;
}

internal static ArgumentException BadParameterName(string parameterName)
{
ArgumentException e = new ArgumentException(SR.GetString(SR.ADP_BadParameterName, parameterName));
return e;
}

internal static void CheckArgumentNull(object value, string parameterName)
{
if (null == value)
Expand All @@ -257,8 +261,6 @@ internal static void CheckArgumentNull(object value, string parameterName)
}
}



internal static bool IsCatchableExceptionType(Exception e)
{
return !((e is NullReferenceException) ||
Expand Down Expand Up @@ -304,6 +306,13 @@ internal static ArgumentOutOfRangeException InvalidCommandType(CommandType value
return InvalidEnumerationValue(typeof(CommandType), (int)value);
}

internal static void ValidateCommandBehavior(CommandBehavior value)
{
if (((int)value < 0) || (0x3F < (int)value))
{
throw InvalidEnumerationValue(typeof(CommandBehavior), (int)value);
}
}

// IDbConnection.BeginTransaction, OleDbTransaction.Begin
internal static ArgumentOutOfRangeException InvalidIsolationLevel(IsolationLevel value)
Expand Down Expand Up @@ -361,6 +370,15 @@ internal static ArgumentOutOfRangeException InvalidUpdateRowSource(UpdateRowSour
return InvalidEnumerationValue(typeof(UpdateRowSource), (int)value);
}

internal static ArgumentOutOfRangeException NotSupportedCommandBehavior(CommandBehavior value, string method)
{
return NotSupportedEnumerationValue(typeof(CommandBehavior), value.ToString(), method);
}

internal static ArgumentOutOfRangeException NotSupportedEnumerationValue(Type type, string value, string method)
{
return ADP.ArgumentOutOfRange(SR.GetString(SR.ADP_NotSupportedEnumerationValue, type.Name, value, method), type.Name);
}

//
// DbConnectionOptions, DataAccess
Expand Down Expand Up @@ -813,7 +831,6 @@ internal static Exception TransactionZombied(DbTransaction obj)
return InvalidOperation(SR.GetString(SR.ADP_TransactionZombied, obj.GetType().Name));
}


// global constant strings
internal const string Parameter = "Parameter";
internal const string ParameterName = "ParameterName";
Expand All @@ -826,11 +843,24 @@ internal static Exception TransactionZombied(DbTransaction obj)
internal const int DefaultConnectionTimeout = DbConnectionStringDefaults.ConnectTimeout;
internal const float FailoverTimeoutStep = 0.08F; // fraction of timeout to use for fast failover connections

// security issue, don't rely upon public static readonly values - AS/URT 109635
internal static readonly String StrEmpty = ""; // String.Empty
// security issue, don't rely upon public static readonly values
internal static readonly string StrEmpty = ""; // String.Empty

internal const int CharSize = sizeof(char);

internal static Delegate FindBuilder(MulticastDelegate mcd)
{
if (null != mcd)
{
foreach (Delegate del in mcd.GetInvocationList())
{
if (del.Target is DbCommandBuilder)
return del;
}
}

return null;
}

internal static void TimerCurrent(out long ticks)
{
Expand Down Expand Up @@ -891,7 +921,7 @@ private static long TimerToSeconds(long timerValue)
return result;
}

internal static string MachineName()
internal static string MachineName()
{
return Environment.MachineName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.



//------------------------------------------------------------------------------

using System.Runtime.Serialization;

namespace System.Data
Expand Down
Loading