Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use indirection and inheritance! If you're performing data access through an abstract Database class, require the Database implementation handle parameter binding.</p> <pre><code>public abstract class Database { private readonly DbProviderFactory factory; protected Database(DbProviderFactory factory) { this.factory = factory; } public virtual DbCommand CreateCommand(String commandText) { return CreateCommand(CommandType.Text, commandText); } public virtual DbCommand CreateCommand(CommandType commandType, String commandText) { DbCommand command = factory.CreateCommand(); command.CommandType = commandType; command.Text = commandText; return command; } public virtual void BindParametersByName(DbCommand command) { } } </code></pre> <p>And choose to create an Oracle specific implementation that overrides default command creation or provides the option to bind parameters by name.</p> <pre><code>public class OracleDatabase : Database { public OracleDatabase() : base(OracleClientFactory.Instance) { } public override DbCommand CreateCommand(CommandType commandType, String commandText) { DbCommand command = base.CreateCommand(commandType, commandText); BindParametersByName(command); return command; } public override void BindParametersByName(DbCommand command) { ((OracleCommand)command).BindByName = true; } } </code></pre> <p><em>Code based on the <a href="http://msdn.microsoft.com/en-us/library/dd203144.aspx" rel="nofollow noreferrer">Data Access Application Block</a> in the <a href="http://msdn.microsoft.com/en-us/library/cc467894.aspx" rel="nofollow noreferrer">Enterprise Library</a>.</em></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload