This thin DbCommand subclass avoids adding a dependency to a specific DbCommand implementation
Inheritance: System.Data.Common.DbCommand
 public void QuestionMarksAreReplacedWithOracleCompatiblePlaceholders()
 {
     var descriptor = (OdpDescriptor)ConnectionDescriptor.LoadFromConfig(
                 new Config("..\\..\\Tests\\dao.config", "DaoConfig"), "NonSpatialDao");
     const string initialSql = "SELECT * FROM TABLE WHERE COL = ? AND COL2 = ?";
     const string expectedSql = "SELECT * FROM TABLE WHERE COL = :param0 AND COL2 = :param1";
     var command = new TestCommand(initialSql);
     descriptor.SetParametersOnCommand(command, new [] {"foo", "bar"});
     Assert.AreEqual(expectedSql, command.CommandText);
     Assert.AreEqual(2, command.Parameters.Count, "Expected 2 parameters to be created on the command.");
     AssertDbParameter(command.Parameters[0], "param0", "foo");
     AssertDbParameter(command.Parameters[1], "param1", "bar");
 }
Beispiel #2
0
 public void FindParametersThrowsIfACommandIsTableDirect()
 {
     var cmd = new TestCommand { CommandText = "SomeTable", CommandType = CommandType.TableDirect };
     AssertParameterPlaceholders(cmd);
 }
Beispiel #3
0
 public void FindParametersThrowsIfACommandisStoredProcedure()
 {
     var cmd = new TestCommand { CommandText = "spSomeProc", CommandType = CommandType.StoredProcedure };
     AssertParameterPlaceholders(cmd);
 }
Beispiel #4
0
 public void FindParameterPlaceholdersInACommand()
 {
     var cmd = new TestCommand("SELECT NAME FROM TABLE WHERE \"COL?\" = ?");
     AssertParameterPlaceholders(cmd, cmd.CommandText.Length - 1);
 }