ExecuteXmlReaderAsync

Overload List:

The method ExecuteXmlReaderAsync returns a Task-based asynchronous version of OracleCommand.ExecuteXmlReader(), which fetches the result set as an XmlReader object.

  • ExecuteXmlReaderAsync()

    This method returns a Task-based asynchronous version of OracleCommand.ExecuteXmlReader(), which fetches the result set as an XmlReader object.

  • ExecuteXmlReaderAsync(CancellationToken)

    This method returns a Task-based asynchronous version of OracleCommand.ExecuteXmlReader(), which fetches the result set as an XmlReader object.

Example (includes overloads)

using Oracle.ManagedDataAccess.Client;
using System;
using System.Threading;
using System.Xml;

namespace AsyncApp
{
  class AsyncDemo
  {
    static async Task Main()
    {
      string connectionString = "User Id=HR; Password=<PASSWORD>; Data Source=oracle;";
      OracleConnection oc = new OracleConnection(connectionString);
      await oc.OpenAsync(CancellationToken.None);

      OracleCommand cmd = oc.CreateCommand();
      cmd.CommandText = "select * from demo_table";

      XmlReader reader;

      reader = await cmd.ExecuteXmlReaderAsync();
      while (reader.Read())
      {
        Console.WriteLine(reader.Value);
      }

      reader = await cmd.ExecuteXmlReaderAsync(CancellationToken.None);
      while (reader.Read())
      {
        Console.WriteLine(reader.Value);
      }
    }
  }
}