Example #1
0
        protected SqlResult ExecuteReader(
            IDbConnection connection,
            string commandText,
            int timeLimit = DefaultTimeLimit)
        {
            using (var command = connection.CreateCommand())
            {
                command.CommandText = commandText;

                using (var reader = command.ExecuteReader())
                {
                    var sqlTestResult = new SqlResult();
                    sqlTestResult.Completed = CodeHelpers.ExecuteWithTimeLimit(
                        TimeSpan.FromMilliseconds(timeLimit),
                        () =>
                    {
                        do
                        {
                            while (reader.Read())
                            {
                                for (var i = 0; i < reader.FieldCount; i++)
                                {
                                    var fieldValue = this.GetDataRecordFieldValue(reader, i);

                                    sqlTestResult.Results.Add(fieldValue);
                                }
                            }
                        }while (reader.NextResult());
                    });

                    return(sqlTestResult);
                }
            }
        }
Example #2
0
        protected bool ExecuteNonQuery(IDbConnection connection, string commandText, int timeLimit = DefaultTimeLimit)
        {
            using (var command = connection.CreateCommand())
            {
                command.CommandText = this.FixCommandText(commandText);

                return(CodeHelpers.ExecuteWithTimeLimit(
                           TimeSpan.FromMilliseconds(timeLimit),
                           () => command.ExecuteNonQuery()));
            }
        }