public void BuildCommandForSqlQueryWithStoredProcedureWithParameters() { var command = new OleDbCommand(); var sqlQuery = new SqlQuery( "CALL GetTableContents @identifier, @Cust_Name", 100, "hello"); var dbDriver = new MySqlDbDriver(); dbDriver.BuildCommand(command, sqlQuery); // The command text should only contain the stored procedure name. Assert.Equal("GetTableContents", command.CommandText); Assert.Equal(CommandType.StoredProcedure, command.CommandType); Assert.Equal(2, command.Parameters.Count); var parameter1 = (IDataParameter)command.Parameters[0]; Assert.Equal(DbType.Int32, parameter1.DbType); Assert.Equal(ParameterDirection.Input, parameter1.Direction); Assert.Equal("@identifier", parameter1.ParameterName); Assert.Equal(sqlQuery.Arguments[0].Value, parameter1.Value); var parameter2 = (IDataParameter)command.Parameters[1]; Assert.Equal(DbType.String, parameter2.DbType); Assert.Equal(ParameterDirection.Input, parameter2.Direction); Assert.Equal("@Cust_Name", parameter2.ParameterName); Assert.Equal(sqlQuery.Arguments[1].Value, parameter2.Value); }
public void BuildCommandForSqlQueryWithSqlTextWhichUsesSameParameterTwice() { var command = new OleDbCommand(); var sqlQuery = new SqlQuery( "SELECT * FROM `Table` WHERE `Table`.`Id` = @p0 AND `Table`.`Value1` = @p1 OR @p1 IS NULL", 100, "hello"); var dbDriver = new MySqlDbDriver(); dbDriver.BuildCommand(command, sqlQuery); Assert.Equal(sqlQuery.CommandText, command.CommandText); Assert.Equal(CommandType.Text, command.CommandType); Assert.Equal(2, command.Parameters.Count); var parameter1 = (IDataParameter)command.Parameters[0]; Assert.Equal(DbType.Int32, parameter1.DbType); Assert.Equal(ParameterDirection.Input, parameter1.Direction); Assert.Equal("@p0", parameter1.ParameterName); Assert.Equal(sqlQuery.Arguments[0].Value, parameter1.Value); var parameter2 = (IDataParameter)command.Parameters[1]; Assert.Equal(DbType.String, parameter2.DbType); Assert.Equal(ParameterDirection.Input, parameter2.Direction); Assert.Equal("@p1", parameter2.ParameterName); Assert.Equal(sqlQuery.Arguments[1].Value, parameter2.Value); }
public void BuildCommandForSqlQueryWithStoredProcedureWithoutParameters() { var command = new OleDbCommand(); var sqlQuery = new SqlQuery("CALL GetTableContents"); var dbDriver = new MySqlDbDriver(); dbDriver.BuildCommand(command, sqlQuery); // The command text should only contain the stored procedure name. Assert.Equal("GetTableContents", command.CommandText); Assert.Equal(CommandType.StoredProcedure, command.CommandType); Assert.Equal(0, command.Parameters.Count); }
public void SupportsBatchedQueriesReturnsTrue() { var dbDriver = new MySqlDbDriver(); Assert.True(dbDriver.SupportsBatchedQueries); }
public WhenCallingCombine_WithTwoSqlQueries() { this.sqlQuery1 = new SqlQuery("SELECT `Column1`, `Column2`, `Column3` FROM `dbo`.`Table1` WHERE `Column1` = @p0 AND `Column2` > @p1", "Foo", 100); this.sqlQuery1.Timeout = 38; this.sqlQuery2 = new SqlQuery("SELECT `Column_1`, `Column_2` FROM `dbo`.`Table_2` WHERE (`Column_1` = @p0 OR @p0 IS NULL) AND `Column_2` < @p1", "Bar", -1); this.sqlQuery2.Timeout = 42; var dbDriver = new MySqlDbDriver(); this.combinedQuery = dbDriver.Combine(this.sqlQuery1, this.sqlQuery2); }
public WhenCallingCombine_WithAnTwoSqlQueries_AndAnSqlQueryIsForAStoredProcedure() { this.sqlQuery1 = new SqlQuery("SELECT `Column1`, `Column2`, `Column3` FROM `dbo`.`Table1` WHERE `Column1` = @p0 AND `Column2` > @p1", "Foo", 100); this.sqlQuery2 = new SqlQuery("CALL CustomersByStatus @StatusId", 2); var dbDriver = new MySqlDbDriver(); this.combinedQuery = dbDriver.Combine(this.sqlQuery1, this.sqlQuery2); }