Exemplo n.º 1
0
        /// <summary>
        /// Format sql using the FormatSql method available in the current <see cref="MiniProfilerBaseOptions.SqlFormatter"/>.
        /// </summary>
        /// <param name="sqlFormatter">The <see cref="ISqlFormatter"/> to use.</param>
        /// <param name="commandText">The SQL command to format.</param>
        /// <param name="parameters">The parameters for the SQL command.</param>
        /// <param name="command">The <see cref="IDbCommand"/> being represented.</param>
        /// <remarks>It is preferable to use this rather than accessing <see cref="ISqlFormatter.FormatSql"/> directly,
        /// as this method will detect whether an <see cref="IAdvancedSqlFormatter"/> is being used, and will access it properly.
        /// This may be removed in a future major version when <see cref="IAdvancedSqlFormatter"/> can be consolidated back
        /// into <see cref="ISqlFormatter"/>.
        /// </remarks>
        public static string GetFormattedSql(this ISqlFormatter sqlFormatter, string commandText, List <SqlTimingParameter> parameters, IDbCommand command = null)
        {
            var advancedFormatter = sqlFormatter as IAdvancedSqlFormatter;

            return(advancedFormatter?.FormatSql(commandText, parameters, command)
                   ?? sqlFormatter.FormatSql(commandText, parameters));
        }
Exemplo n.º 2
0
        public async Task RunAsync(string[] args)
        {
            if (args.Length < 3)
            {
                throw new ArgumentException(nameof(args));
            }

            string directory = args.First();

            string[] fileNames = args.Skip(1).Take(2).ToArray();

            string sql = _preparator.PrepareFullJoinSql(directory, fileNames);

            sql = _formatter.FormatSql(sql);

            string connectionString = GetConnectionString(directory);

            await _executor.ExecuteSqlAsync(
                sql,
                connectionString,
                Output);

            await _saver.SaveSqlAsync(sql, SqlPath);
        }