1
votes

I'm migrating code that uses ADO.NET/ODP.NET to Enterprise Library 6.0. I'm using the EntLibContrib project that adds support for ODP.NET. There are some optimizations made in the ADO.NET code and I'm trying to determine how to call those properties with EL.

The ADO.NET looks like this:

 using (OracleConnection conn = new OracleConnection(_connectionString))
 {
     using (OracleCommand cmd = new OracleCommand(command, conn))
     {
          cmd.CommandType = CommandType.Text;
          cmd.InitialLOBFetchSize = -1;

          cmd.Connection.Open();
          OracleDataReader reader = cmd.ExecuteReader();
          reader.FetchSize = reader.RowSize * 1000;
          reader.Read();

         [...]
    }
}

EL code looks like:

var database = new DatabaseProviderFactory().CreateDefault();

using (var reader = database.ExecuteReader(CommandType.Text, command))
{
 [...]
}

I'm also updating Stored Procedures as well here are the examples.

ADO.NET:

using (OracleConnection conn = new OracleConnection(_connectionString))
{
  using (OracleCommand cmd = new OracleCommand(command, conn))
  {
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add("pID", OracleDbType.Int32).Value = eID;
    OracleParameter pResults = cmd.Parameters.Add("pResults", OracleDbType.RefCursor, ParameterDirection.Output);

    cmd.Connection.Open();
    cmd.ExecuteNonQuery();

    using (OracleRefCursor cursor = pResults.Value as OracleRefCursor)
    {
        using (OracleDataReader reader = cursor.GetDataReader())
        {
           reader.FetchSize = reader.RowSize * 1000;

           while (reader.Read())
           {
             [...]
           }

To EL:

var database = new DatabaseProviderFactory().CreateDefault();

using (var reader = database.ExecuteReader("SS.SP_GET_TASKDATA_BY_PRAC", practiceID, firstRow, lastRow))
{
  while (reader.Read())
  {
     [...]
  }

How do I set the FetchSize and InitialLOBFetchSize properties with my EL code?

1
did you tried and get any solution using EL code finally ?PreguntonCojoneroCabrón

1 Answers

0
votes

I imagine that this has long since been solved, but I think that you can do the following (at least with EF5, not sure about 6):

SQL Query

var cmd = database.GetSqlStringCommand(command);
var ocmd = (OracleCommand)cmd;
ocmd.InitialLOBFetchSize = -1;

using (var reader = database.ExecuteReader(cmd))
{
  ...
}

Stored Proc

var cmd = database.GetStoredProcCommand("SS.SP_GET_TASKDATA_BY_PRAC", practiceID, firstRow, lastRow );

var ocmd = (OracleCommand)cmd;
ocmd.InitialLOBFetchSize = -1;

using (var reader = database.ExecuteReader(cmd))
{
...
}

EDIT: You can also set FetchSize on the ocmd in the same way.