示例#1
0
        /// <summary>
        /// Adds a new command step to the step list.
        /// </summary>
        /// <param name="step">The step to add.</param>
        /// <returns>
        /// A reference to this batch instance.
        /// </returns>
        public ICommandBatch Add(ICommandBatchStep step)
        {
            if (this.CurrentCount >= this.Connector.Configuration.MaxCommandsPerBatch)
            {
                return(null);
            }

            if (this.MaxCount > 0 && this.CurrentCount >= this.MaxCount)
            {
                return(null);
            }

            if (this.ParameterCount + step.Command.Parameters.Count() >= this.Connector.Configuration.MaxParametersPerCommand)
            {
                return(null);
            }

            if (this.CommandText != null && this.CommandText.Length >= this.Connector.Configuration.MaxCommandLength)
            {
                return(null);
            }

            this.AddCommand(step.Command);
            this.CurrentCount++;

            if (step.BatchResultCallback != null || step.BatchResultCallbackAsync != null)
            {
                this.Steps.Add(step);
            }

            return(this);
        }
示例#2
0
        /// <summary>
        /// Adds the specified command to the current batch.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <returns>
        /// Returns the batch manager instance.
        /// </returns>
        /// <exception cref="System.Exception">The command can not be added to the batch, probably it has too many parameters.</exception>
        public IBatchManager Add(ICommandBatchStep command)
        {
            var batch = this.GetCurrentBatch().Add(command);

            if (batch == null)
            {
                this.CurrentBatch = null;
                batch             = this.GetCurrentBatch().Add(command);

                if (batch == null)
                {
                    throw new Exception("The command can not be added to the batch, probably it has too many parameters.");
                }
            }

            return(this);
        }