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

Commit

Permalink
Correct source field is used to get column ordinal. (#24655)
Browse files Browse the repository at this point in the history
  • Loading branch information
satano authored and saurabh500 committed Nov 5, 2017
1 parent a9cf418 commit 552ef49
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/System.Data.SqlClient/src/System/Data/SqlClient/SqlBulkCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private enum ValueSourceType
DbDataReader
}

// Enum for specifying SqlDataReader.Get method used
// Enum for specifying SqlDataReader.Get method used
private enum ValueMethod : byte
{
GetValue,
Expand Down Expand Up @@ -217,7 +217,7 @@ public SourceColumnMetadata(ValueMethod method, bool isSqlType, bool isDataFeed)
private SourceColumnMetadata[] _currentRowMetadata;

#if DEBUG
internal static bool _setAlwaysTaskOnWrite = false; //when set and in DEBUG mode, TdsParser::WriteBulkCopyValue will always return a task
internal static bool _setAlwaysTaskOnWrite = false; //when set and in DEBUG mode, TdsParser::WriteBulkCopyValue will always return a task
internal static bool SetAlwaysTaskOnWrite
{
set
Expand Down Expand Up @@ -402,7 +402,7 @@ void IDisposable.Dispose()

private bool IsCopyOption(SqlBulkCopyOptions copyOption) => ((_copyOptions & copyOption) == copyOption);

//Creates the initial query string, but does not execute it.
//Creates the initial query string, but does not execute it.
private string CreateInitialQuery()
{
string[] parts;
Expand Down Expand Up @@ -479,9 +479,9 @@ private string CreateInitialQuery()
}

// Creates and then executes initial query to get information about the targettable
// When __isAsyncBulkCopy == false (i.e. it is Sync copy): out result contains the resulset. Returns null.
// When __isAsyncBulkCopy == true (i.e. it is Async copy): This still uses the _parser.Run method synchronously and return Task<BulkCopySimpleResultSet>.
// We need to have a _parser.RunAsync to make it real async.
// When __isAsyncBulkCopy == false (i.e. it is Sync copy): out result contains the resulset. Returns null.
// When __isAsyncBulkCopy == true (i.e. it is Async copy): This still uses the _parser.Run method synchronously and return Task<BulkCopySimpleResultSet>.
// We need to have a _parser.RunAsync to make it real async.
private Task<BulkCopySimpleResultSet> CreateAndExecuteInitialQueryAsync(out BulkCopySimpleResultSet result)
{
string TDSCommand = CreateInitialQuery();
Expand Down Expand Up @@ -1034,7 +1034,7 @@ private Task ReadFromRowSourceAsync(CancellationToken cts)
{
if (_isAsyncBulkCopy && _DbDataReaderRowSource != null)
{
// This will call ReadAsync for DbDataReader (for SqlDataReader it will be truly async read; for non-SqlDataReader it may block.)
// This will call ReadAsync for DbDataReader (for SqlDataReader it will be truly async read; for non-SqlDataReader it may block.)
return _DbDataReaderRowSource.ReadAsync(cts).ContinueWith((t) =>
{
if (t.Status == TaskStatus.RanToCompletion)
Expand Down Expand Up @@ -1488,7 +1488,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
case TdsEnums.SQLUDT:
throw ADP.DbTypeNotSupported("UDT");
case TdsEnums.SQLXMLTYPE:
// Could be either string, SqlCachedBuffer, XmlReader or XmlDataFeed
// Could be either string, SqlCachedBuffer, XmlReader or XmlDataFeed
Debug.Assert((value is XmlReader) || (value is SqlCachedBuffer) || (value is string) || (value is SqlString) || (value is XmlDataFeed), "Invalid value type of Xml datatype");
if (value is XmlReader)
{
Expand Down Expand Up @@ -1963,7 +1963,7 @@ private void WriteRowSourceToServerCommon(int columnCount)
case ValueSourceType.IDataReader:
try
{
index = _DbDataReaderRowSource.GetOrdinal(unquotedColumnName);
index = ((IDataReader)_rowSource).GetOrdinal(unquotedColumnName);
}
catch (IndexOutOfRangeException e)
{
Expand Down Expand Up @@ -2926,4 +2926,4 @@ private Task WriteToServerInternalAsync(CancellationToken ctoken)
return resultTask;
}
}
}
}

0 comments on commit 552ef49

Please sign in to comment.