Skip to content

Commit c0ba212

Browse files
committed
Address feedback from @edwardneal
1 parent 6a89074 commit c0ba212

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Reader.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ private _SqlRPC BuildExecute(bool inSchema)
435435
/// </summary>
436436
/// <remarks>
437437
/// Prototype for sp_executesql is:
438-
/// sqp_executesql(@batch_text nvarchar(4000), @batch_params nvarchar(4000), param1, param2, ...)
438+
/// sp_executesql(@batch_text nvarchar(4000), @batch_params nvarchar(4000), param1, param2, ...)
439439
/// </remarks>
440440
// @TODO Does parameters need to be passed in or can _parameters be used?
441441
// @TODO: Can we return the RPC here like BuildExecute does?
@@ -648,7 +648,7 @@ private SqlDataReader EndExecuteReaderAsync(IAsyncResult asyncResult)
648648
"SqlCommand.EndExecuteReaderAsync | API | Correlation | " +
649649
$"Object Id {ObjectID}, " +
650650
$"Activity Id {ActivityCorrelator.Current}, " +
651-
$"Client Connection Id {_activeConnection.ClientConnectionId}, " +
651+
$"Client Connection Id {_activeConnection?.ClientConnectionId}, " +
652652
$"Command Text '{CommandText}'");
653653

654654
Exception asyncException = ((Task)asyncResult).Exception;
@@ -802,7 +802,7 @@ private void FinishExecuteReader(
802802
_stateObj = null; // The reader now owns this...
803803
ds.ResetOptionsString = resetOptionsString;
804804

805-
// Bind the reader to this connectio now
805+
// Bind the reader to this connection now
806806
_activeConnection.AddWeakReference(ds, SqlReferenceCollection.DataReaderTag);
807807

808808
// Force this command to start reading data off the wire.
@@ -1015,6 +1015,13 @@ private Task<SqlDataReader> InternalExecuteReaderAsync(
10151015
}
10161016
catch (Exception e)
10171017
{
1018+
#if NET
1019+
if (!_parentOperationStarted)
1020+
{
1021+
s_diagnosticListener.WriteCommandBefore(operationId, this, _transaction, e);
1022+
}
1023+
#endif
1024+
10181025
source.SetException(e);
10191026
context?.Dispose();
10201027
}
@@ -1060,6 +1067,7 @@ private SqlDataReader InternalEndExecuteReader(IAsyncResult asyncResult, bool is
10601067
}
10611068

10621069
// @TODO: We're passing way too many arguments around here... can we simplify this some?
1070+
// task is created in case of pending asynchronous write, returned SqlDataReader should not be utilized until that task is complete
10631071
private SqlDataReader RunExecuteReader(
10641072
CommandBehavior cmdBehavior,
10651073
RunBehavior runBehavior,
@@ -1215,7 +1223,6 @@ private SqlDataReader RunExecuteReader(
12151223
else
12161224
{
12171225
// @TODO: Reminder, this is where we execute if transparent parameter encryption is not needed.
1218-
usedCache = false;
12191226
return RunExecuteReaderTds(
12201227
cmdBehavior,
12211228
runBehavior,
@@ -1516,7 +1523,7 @@ private SqlDataReader RunExecuteReaderTds(
15161523
throw SQL.SynchronousCallMayNotPend();
15171524
}
15181525

1519-
// And turn OF Fwhen the ds exhausts the stream on Close()
1526+
// And turn OFF when the ds exhausts the stream on Close()
15201527
optionSettings = GetResetOptionsString(cmdBehavior);
15211528
}
15221529

0 commit comments

Comments
 (0)