Topics: Data Access Application Block
Jul 29, 2007 at 8:56 AM
Is this EntLib3.1 method supposed to cache the parameters? I thought it was, but when I profile my inserts, spprocedureparamsrowset is being excecuted each time I call GetDbCommand. (see below) Perhaps I'm doing something incorrectly or mis-understanding what the method is intended to do?

My code structure is fairly simple. I have several DAC classes inheriting a BaseDAC class. In the BaseDAC class I have:

...my database...
protected internal SqlDatabase SqlDb = new SqlDatabase(ConfigurationManager.ConnectionStrings"XXXXX".ToString());

...a couple generic DbCommand methods...
protected DbCommand GetDbCommand(string spName)
return GetDbCommand(spName, SqlDb);

protected DbCommand GetDbCommand(string spName, SqlDatabase db)
// create the db command
DbCommand cmdDB = db.GetStoredProcCommand(spName);

// discover the parameters (this will also cache them)
db.DiscoverParameters(cmdDB); //not caching...??

// return the DbCommand Parameters collection
return cmdDB;

Am I missing something?

Thank you, Reed
Jul 30, 2007 at 12:14 PM
Hi Reed,

Parameters are cached only when you invoke a store procedure with the method that gets the parameter values as well, like public virtual int ExecuteNonQuery(string storedProcedureName, params object[] parameterValues).