public System.Xml.XmlReader ExecuteXmlReader() { throw null; }
public System.Threading.Tasks.Task<System.Xml.XmlReader> ExecuteXmlReaderAsync() { throw null; }
public System.Threading.Tasks.Task<System.Xml.XmlReader> ExecuteXmlReaderAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
+ public System.IAsyncResult BeginExecuteXmlReader() { throw null; }
+ public System.IAsyncResult BeginExecuteXmlReader(System.AsyncCallback callback, object stateObject) { throw null; }
+ public System.Xml.XmlReader EndExecuteXmlReader(System.IAsyncResult asyncResult) { throw null; }
public override void Prepare() { }
public System.Data.Sql.SqlNotificationRequest Notification { get { throw null; } set { } }
public void ResetCommandTimeout() { }
}
- private IAsyncResult BeginExecuteXmlReader(AsyncCallback callback, object stateObject)
+ public IAsyncResult BeginExecuteXmlReader()
+ {
+ return BeginExecuteXmlReader(null, null);
+ }
+
+ public IAsyncResult BeginExecuteXmlReader(AsyncCallback callback, object stateObject)
{
// Reset _pendingCancel upon entry into any Execute - used to synchronize state
// between entry into Execute* API and the thread obtaining the stateObject.
}
- private XmlReader EndExecuteXmlReader(IAsyncResult asyncResult)
+ public XmlReader EndExecuteXmlReader(IAsyncResult asyncResult)
{
Exception asyncException = ((Task)asyncResult).Exception;
if (asyncException != null)
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+using Xunit;
+
+namespace System.Data.SqlClient.ManualTesting.Tests
+{
+ public static class XmlReaderAsyncTest
+ {
+ private static string commandText =
+ "SELECT * from dbo.Customers FOR XML AUTO, XMLDATA;";
+
+ [CheckConnStrSetupFact]
+ public static void ExecuteTest()
+ {
+ using (SqlConnection connection = new SqlConnection(DataTestUtility.TcpConnStr))
+ {
+ SqlCommand command = new SqlCommand(commandText, connection);
+ connection.Open();
+
+ IAsyncResult result = command.BeginExecuteXmlReader();
+ while (!result.IsCompleted)
+ {
+ System.Threading.Thread.Sleep(100);
+ }
+
+ XmlReader reader = command.EndExecuteXmlReader(result);
+
+ reader.ReadToDescendant("dbo.Customers");
+ Assert.Equal("ALFKI", reader["CustomerID"]);
+ }
+ }
+
+ [CheckConnStrSetupFact]
+ public static void ExceptionTest()
+ {
+ using (SqlConnection connection = new SqlConnection(DataTestUtility.TcpConnStr))
+ {
+ SqlCommand command = new SqlCommand(commandText, connection);
+ connection.Open();
+
+ //Try to execute a synchronous query on same command
+ IAsyncResult result = command.BeginExecuteXmlReader();
+
+ Assert.Throws<InvalidOperationException>( delegate { command.ExecuteXmlReader(); });
+
+ while (!result.IsCompleted)
+ {
+ System.Threading.Thread.Sleep(100);
+ }
+
+ XmlReader reader = command.EndExecuteXmlReader(result);
+
+ reader.ReadToDescendant("dbo.Customers");
+ Assert.Equal("ALFKI", reader["CustomerID"]);
+ }
+ }
+ }
+}
<Compile Include="DataCommon\CheckConnStrSetupFactAttribute.cs" />
<Compile Include="SQL\AdapterTest\AdapterTest.cs" />
<Compile Include="SQL\AsyncTest\BeginExecAsyncTest.cs" />
+ <Compile Include="SQL\AsyncTest\XmlReaderAsyncTest.cs" />
<Compile Include="SQL\Common\AsyncDebugScope.cs" />
<Compile Include="SQL\Common\ConnectionPoolWrapper.cs" />
<Compile Include="SQL\Common\InternalConnectionWrapper.cs" />