diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
index b69dc00a90..8537b27a1e 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
@@ -588,6 +588,9 @@
Microsoft\Data\SqlClient\SqlCommand.Scalar.cs
+
+ Microsoft\Data\SqlClient\SqlCommand.Xml.cs
+
Microsoft\Data\SqlClient\SqlCommandSet.cs
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.netcore.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.netcore.cs
index 90979eeec9..b6a4ff8405 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.netcore.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.netcore.cs
@@ -58,30 +58,6 @@ protected override void AfterCleared(SqlCommand owner)
}
}
- internal sealed class ExecuteXmlReaderAsyncCallContext : AAsyncCallContext
- {
- public Guid OperationID;
-
- public SqlCommand Command => _owner;
- public TaskCompletionSource TaskCompletionSource => _source;
-
- public void Set(SqlCommand command, TaskCompletionSource source, CancellationTokenRegistration disposable, Guid operationID)
- {
- base.Set(command, source, disposable);
- OperationID = operationID;
- }
-
- protected override void Clear()
- {
- OperationID = default;
- }
-
- protected override void AfterCleared(SqlCommand owner)
- {
- owner?.SetCachedCommandExecuteXmlReaderContext(this);
- }
- }
-
///
/// Indicates if the column encryption setting was set at-least once in the batch rpc mode, when using AddBatchCommand.
///
@@ -604,315 +580,11 @@ private void ThrowIfReconnectionHasBeenCanceled()
}
}
- ///
- public XmlReader ExecuteXmlReader()
- {
- // Reset _pendingCancel upon entry into any Execute - used to synchronize state
- // between entry into Execute* API and the thread obtaining the stateObject.
- _pendingCancel = false;
-
- using (DiagnosticScope diagnosticScope = s_diagnosticListener.CreateCommandScope(this, _transaction))
- using (TryEventScope.Create("SqlCommand.ExecuteXmlReader | API | Object Id {0}", ObjectID))
- {
- SqlStatistics statistics = null;
- bool success = false;
- int? sqlExceptionNumber = null;
- SqlClientEventSource.Log.TryCorrelationTraceEvent("SqlCommand.ExecuteXmlReader | API | Correlation | Object Id {0}, Activity Id {1}, Client Connection Id {2}, Command Text '{3}'", ObjectID, ActivityCorrelator.Current, Connection?.ClientConnectionId, CommandText);
-
- try
- {
- statistics = SqlStatistics.StartTimer(Statistics);
- WriteBeginExecuteEvent();
-
- // use the reader to consume metadata
- SqlDataReader ds = IsProviderRetriable ?
- RunExecuteReaderWithRetry(CommandBehavior.SequentialAccess, RunBehavior.ReturnImmediately, returnStream: true) :
- RunExecuteReader(CommandBehavior.SequentialAccess, RunBehavior.ReturnImmediately, returnStream: true);
- success = true;
- return CompleteXmlReader(ds);
- }
- catch (Exception ex)
- {
- diagnosticScope.SetException(ex);
- if (ex is SqlException sqlException)
- {
- sqlExceptionNumber = sqlException.Number;
- }
- throw;
- }
- finally
- {
- SqlStatistics.StopTimer(statistics);
- WriteEndExecuteEvent(success, sqlExceptionNumber, synchronous: true);
- }
- }
- }
-
- ///
- public IAsyncResult BeginExecuteXmlReader()
- {
- // BeginExecuteXmlReader will track executiontime
- return BeginExecuteXmlReader(null, null);
- }
-
- ///
- public IAsyncResult BeginExecuteXmlReader(AsyncCallback callback, object stateObject)
- {
- SqlClientEventSource.Log.TryCorrelationTraceEvent("SqlCommand.BeginExecuteXmlReader | API | Correlation | Object Id {0}, Activity Id {1}, Client Connection Id {2}, Command Text '{3}'", ObjectID, ActivityCorrelator.Current, Connection?.ClientConnectionId, CommandText);
- return BeginExecuteXmlReaderInternal(CommandBehavior.SequentialAccess, callback, stateObject, 0, isRetry: false);
- }
-
- private IAsyncResult BeginExecuteXmlReaderAsync(AsyncCallback callback, object stateObject)
- {
- SqlClientEventSource.Log.TryCorrelationTraceEvent("SqlCommand.BeginExecuteXmlReaderAsync | API | Correlation | Object Id {0}, Activity Id {1}, Client Connection Id {2}, Command Text '{3}'", ObjectID, ActivityCorrelator.Current, Connection?.ClientConnectionId, CommandText);
- return BeginExecuteXmlReaderInternal(CommandBehavior.SequentialAccess, callback, stateObject, CommandTimeout, isRetry: false, asyncWrite: true);
- }
-
- private IAsyncResult BeginExecuteXmlReaderInternal(CommandBehavior behavior, AsyncCallback callback, object stateObject, int timeout, bool isRetry, bool asyncWrite = false)
- {
- TaskCompletionSource