Exemple #1
0
        public void Execute(ISqlCommandSimple command, IExecutionContext context, int index)
        {
            context.StartSetupCommand(index);
            using var dbCommand = context.CreateCommand();
            if (!SetupCommand(command, dbCommand))
            {
                context.MarkAborted();
                return;
            }

            try
            {
                context.StartExecute(index, dbCommand);
                dbCommand.Command.ExecuteNonQuery();
            }
            catch (SqlQueryException)
            {
                context.MarkAborted();
                throw;
            }
            catch (Exception e)
            {
                context.MarkAborted();
                var sql = context.Stringifier.Stringify(dbCommand);
                throw SqlQueryException.Wrap(e, sql, index);
            }
        }
Exemple #2
0
        public string Stringify(ISqlCommandSimple command)
        {
            var dummy = new DummyCommandAsync(new DummyDbCommand());

            new SqlCommandSimpleStrategy().SetupCommand(command, dummy);
            return(_stringifier.Stringify(dummy));
        }
Exemple #3
0
 public T Execute <T>(ISqlCommandSimple <T> command, IExecutionContext context, int index)
 {
     context.StartSetupCommand(index);
     using var dbCommand = context.CreateCommand();
     if (!SetupCommand(command, dbCommand))
     {
         context.MarkAborted();
         return(default);
Exemple #4
0
        public ISqlResultPromise Add(ISqlCommandSimple command)
        {
            Argument.NotNull(command, nameof(command));
            var result = new SqlResultPromise();

            AddExecutor((c, i) =>
            {
                new SqlCommandSimpleStrategy().Execute(command, c, i);
                result.SetComplete();
            });
            return(result);
        }
 /// <summary>
 /// Execute the command asynchronously and return no result. Maps internally to a call to
 /// IDbCommand.ExecuteNonQuery()
 /// </summary>
 /// <param name="runner"></param>
 /// <param name="command"></param>
 /// <returns></returns>
 public static Task ExecuteAsync(this ISqlRunner runner, ISqlCommandSimple command, CancellationToken cancellationToken = new CancellationToken())
 {
     Argument.NotNull(runner, nameof(runner));
     Argument.NotNull(command, nameof(command));
     return(runner.ExecuteAsync(c => new SqlCommandSimpleStrategy().ExecuteAsync(command, c, 0, cancellationToken)));
 }
 /// <summary>
 /// Execute the command and return a result. Commands will not
 /// generate an IDataReader or IDataResults, so results will either need to be calculated or
 /// derived from output parameters. Maps internally to a call to IDbCommand.ExecuteNonQuery()
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="runner"></param>
 /// <param name="command"></param>
 /// <returns></returns>
 public static T Execute <T>(this ISqlRunner runner, ISqlCommandSimple <T> command)
 {
     Argument.NotNull(runner, nameof(runner));
     Argument.NotNull(command, nameof(command));
     return(runner.Execute(c => new SqlCommandSimpleStrategy().Execute(command, c, 0)));
 }