EntLib DataAccessBlock

Topics: Data Access Application Block
Jul 29, 2009 at 3:19 PM

Hi,

i made an extension of the EntLib DataAccessBlock to use the native Oracle client ().

Now I only have 1 problem, I would like to control the opening of my DBConnection (sendind some custom command after the .Open() etc... ). The problem is that, in the Database.cs class, the GetOpenConnection() method is an internal method and i can't override it. I can override the CreateConnection() method to create an OracleConnection but i cant add my custom code directly after the .Open() of the connexion because its internal to the block and it can't be customized through extension (EntLib should'nt be customizable throug extension ?).

I've checked for other solution, override all other method in Database.cs that use the GetOpenConnection()method but i failed with few methods.

What i would like to see in EntLib5 is more extendable method !

Jul 30, 2009 at 11:45 AM
Edited Jul 30, 2009 at 11:59 AM

Hi,

Nothing stops you from modifying the source code if it will fit your need.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

 

Jul 30, 2009 at 2:25 PM

Yes, thats is what i will probably end to do. But I also wanted to let you know so maybe it could be changed in the next version of the block.

 

Thx

Aug 14, 2009 at 8:41 PM

abyshai,

I am trying to do the same thing that you have done.  I have created my own dll that extends the DAAB.  I the OracleDatabase class use ODP .Net (Oracle.DataAccess.Client).  However, I am unable to execute queries with bind variables.  For example when I try something like this:

Database db = DatabaseFactory.CreateDatabase("MyDB");
string sqlCommand = "Insert Into TableName Values (:A, :B)

";
                DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, ":A", DbType.String, "ValueA");
                db.AddInParameter(dbCommand, ":B", DbType.String, "valueB");
               

                int recsAffected = db.ExecuteNonQuery(dbCommand);

The variables are bound, but the values for the parameter are null when the query executes.

Have you come across this issue?  If so what did you do to resolve it?  How exactly did you make the extension?

I would appreciate any help.

 

Thanks,

VT.

 

Aug 17, 2009 at 5:37 AM

Replied on this thread - http://entlib.codeplex.com/Thread/View.aspx?ThreadId=65500

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 17, 2009 at 5:50 PM

Changed the code to something similar to the following and it works:

Database db = DatabaseFactory.CreateDatabase("MyDB");
string sqlCommand = "Insert Into TableName Values (:A, :B)";
DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);
db.AddParameter(dbCommand, "A", DbType.String, 4000, ParameterDirection.Input, false, 6, 0, null, DataRowVersion.Current, "VALUEA");
db.AddParameter(dbCommand, "B", DbType.String, 4000, ParameterDirection.Input, false, 6, 0, null, DataRowVersion.Current, "VALUEB");
int recsAffected = db.ExecuteNonQuery(dbCommand);

The number 4000 is just a arbitrary number that should be equal to or greater than the length of the value you are trying to insert.

VT.