is EntLib Contrib replacing EntLib?

Topics: Development Team Discussion, User Discussion
Oct 26, 2011 at 5:49 PM

Hi All,

    I am just new to entlib contrib and the online docs are not very clear. Is it some sort of replacing the ent lib since the down load including the same dll as the ent lib but with different ver(5.0.505.0) than Microsoft ver (5.0.414.0) or they should work together?

Thank you

Jim

Coordinator
Oct 26, 2011 at 5:55 PM
Edited Oct 26, 2011 at 6:17 PM

Hi Jim,

EntLibContrib is actually extending the EntLib blocks and include new ones. And the v5 version of EntLibContrib is targetting the NuGet version of EntLib (which is 5.0.505.0).

Cheers,

Jeremi

Oct 26, 2011 at 6:19 PM

Thank you so much Jeremi,

That was actually confusing because I downloaded the ent lib from the ms site not from NuGet and I didn't know that there is a new one released.

 Also I am trying to use ODP.NET provider but I don't see much support for oracle cursor except some work around like passing null to the out parameters like the code in the below link. Do you think I miss something or my understanding is correct?

http://devstuffs.wordpress.com/2010/08/24/enterprise-library-5-with-oracle-cursor/

However if you use Oracle.Dataaccess directly.

you can write code like this:

 

Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>();
     OracleConnection con = new OracleConnection(db.ConnectionString);
         con.Open();
       OracleCommand cmd = con.CreateCommand();
        cmd.CommandText = "LookupData";
           cmd.CommandType = System.Data.CommandType.StoredProcedure;
  cmd.Parameters.Add("id", OracleDbType.Decimal).Value = GroupId;
           cmd.Parameters.Add("cursor", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
           cmd.Parameters.Add("return_status", OracleDbType.Varchar2, 1).Direction = ParameterDirection.Output;
          cmd.Parameters.Add("data", OracleDbType.Varchar2, 2000).Direction = ParameterDirection.Output;
         var rdr = cmd.ExecuteReader();

 

Any help much appreciated

Best regards,

Jim

Coordinator
Oct 29, 2011 at 5:42 AM

Hi Jim,

the ref cursor parameter is automatically added to the command by the OracleDatabase object when calling the ExecuteXXXX() methods. But you can also add it yourself to your command object if needed (look to the code calling the AddParameter method below).

public override IDataReader ExecuteReader(DbCommand command)
{
 PrepareCWRefCursor(command);
        return base.ExecuteReader(command);
}

private void PrepareCWRefCursor(DbCommand command)
{
 if (command == null) throw new ArgumentNullException("command");

 if (CommandType.StoredProcedure == command.CommandType)
 {
  // Check for ref. cursor in the command writer, if it does not exist, add a known reference cursor out
  // of "cur_OUT"
  if (QueryProcedureNeedsCursorParameter(command))
  {
   AddParameter(command as OracleCommand, RefCursorName, OracleDbType.RefCursor, 0, ParameterDirection.Output, true, 0, 0, String.Empty, DataRowVersion.Default, Convert.DBNull);
  }
 }
}

Hope it help?

Jeremi

Oct 31, 2011 at 6:36 AM

Thank you Jeremi, that is very helpful for sure

Best regards,

Jim