public virtual Tuple <Database, DbCommand, DatabaseParameterCollection> SetUpCommand(String text, CommandType type, Action <DatabaseParameterCollection> parametersFunc = null)
        {
            if (String.IsNullOrWhiteSpace(text))
            {
                throw new ArgumentException("text");
            }

            if (CommandType.StoredProcedure == type)
            {
                if (false == text.Contains("."))
                {
                    text = String.Format("{0}.{1}", SchemaName, text);
                }
            }

            DatabaseParameterCollection parameters = SetUpParameters(parametersFunc);
            Database  db  = GetDataBase();
            DbCommand cmd = null;

            if (CommandType.StoredProcedure == type)
            {
                cmd = db.GetStoredProcCommand(text);
            }

            if (CommandType.Text == type)
            {
                cmd = db.GetSqlStringCommand(text);
            }

            if ((null != parameters) && (null != cmd) && (parameters.Timeout > 0))
            {
                cmd.CommandTimeout = parameters.Timeout;
            }

            if ((null == parameters) || (0 == parameters.Count))
            {
                return(new Tuple <Database, DbCommand, DatabaseParameterCollection>(db, cmd, parameters));
            }

            foreach (DatabaseParameter parameter in parameters)
            {
                if (parameter.Direction == ParameterDirection.Output)
                {
                    db.AddOutParameter(cmd, parameter.Name, parameter.Type, parameter.Size);
                    continue;
                }

                if (parameter.Direction == ParameterDirection.InputOutput)
                {
                    db.AddParameter(cmd, parameter.Name, parameter.Type, parameter.Size, parameter.Direction, false, 0, 0, String.Empty, DataRowVersion.Current, parameter.Value);
                    continue;
                }

                db.AddInParameter(cmd, parameter.Name, parameter.Type, parameter.Value);
            }

            return(new Tuple <Database, DbCommand, DatabaseParameterCollection>(db, cmd, parameters));
        }
        /// <summary>
        /// Sets up parameters.
        /// </summary>
        /// <param name="parametersFunc">The parameters function.</param>
        /// <returns></returns>
        public virtual DatabaseParameterCollection SetUpParameters(Action <DatabaseParameterCollection> parametersFunc = null)
        {
            DatabaseParameterCollection parameters = ((null != parametersFunc) ? (new DatabaseParameterCollection()) : null);

            if (null != parametersFunc)
            {
                parametersFunc(parameters);
            }

            return(parameters);
        }
        public static String GetParametersDescription(Tuple <Database, DbCommand, DatabaseParameterCollection> executeParams)
        {
            if (null == executeParams)
            {
                return("None");
            }

            DatabaseParameterCollection parameters = executeParams.Item3;

            if (null == parameters)
            {
                return("None");
            }

            return(String.Format("Parameter Summary [Timeout:={0}]{1}{2}{1}{3}", parameters.Timeout, System.Environment.NewLine, (new String('-', 80)), parameters));
        }