Esempio n. 1
0
        /// <summary>
        /// Called when [next].
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <exception cref="ArgumentNullException">builder.</exception>
        /// <exception cref="NullReferenceException">
        /// Configuration
        /// or
        /// Query.
        /// </exception>
        public void OnNext(IDataCommandBuilder builder)
        {
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (builder.Configuration is null)
            {
                throw new NullReferenceException(nameof(builder.Configuration));
            }

            if (builder.Configuration.Query is null)
            {
                throw new NullReferenceException(nameof(builder.Configuration.Query));
            }

            if (this.Connection.State != ConnectionState.Open)
            {
                this.autoCommit = true;
                this.Connection.Open();
                this.transaction = this.connection
                                   .InnerConnection
                                   .BeginTransaction(this.il);
            }

            if (this.transaction == null)
            {
                this.transaction = this.connection
                                   .InnerConnection
                                   .BeginTransaction(this.il);
            }

            if (builder.Configuration.Query == null)
            {
                builder.Configuration.Query = this.SqlDialect.CreateBuilder();
            }

            if (builder.Command == null)
            {
                builder.Command = this.CreateCommand();
            }

            builder.Configuration.ParameterPrefix = this.SqlDialect.ParameterPrefixToken;

            builder.ApplyConfiguration();
        }