/// <summary>
        /// 添加所有数据字段名并返回当前SQL语句创建类
        /// </summary>
        /// <param name="isDistinct">是否选择语句唯一</param>
        /// <param name="queryFields">数据字段名</param>
        /// <returns>当前SQL语句创建类</returns>
        internal SqlCommandBuilder AppendAllColumnNames(Boolean isDistinct, List <SqlQueryField> queryFields)
        {
            if (queryFields != null && queryFields.Count > 0)
            {
                StringBuilder names = new StringBuilder();

                for (Int32 i = 0; i < queryFields.Count; i++)
                {
                    if (i > 0)
                    {
                        names.Append(",");
                    }

                    SqlQueryField queryField = queryFields[i];

                    if (queryField.UseFunction)
                    {
                        names.Append(queryField.Function);
                    }

                    if (!String.IsNullOrEmpty(queryField.FieldName))
                    {
                        if (queryField.UseFunction)
                        {
                            names.Append('(');

                            if (queryField.UseDistinct)
                            {
                                names.Append("DISTINCT ");
                            }
                        }

                        if (!String.IsNullOrEmpty(queryField.TableName))
                        {
                            names.Append(queryField.TableName).Append('.');
                        }

                        names.Append(queryField.FieldName);

                        if (queryField.UseFunction)
                        {
                            names.Append(')');
                        }
                    }

                    if (!String.IsNullOrEmpty(queryField.AliasesName))
                    {
                        names.Append(" AS ").Append(queryField.AliasesName);
                    }
                }

                this._stringBuilder.Append(names.ToString()).Append(' ');
            }
            else
            {
                this._stringBuilder.Append("* ");
            }

            return(this);
        }
        /// <summary>
        /// 查询指定字段名并返回当前语句
        /// </summary>
        /// <param name="queryFields">要查询的字段名集合</param>
        /// <returns>当前语句</returns>
        public SelectCommand Querys(params String[] queryFields)
        {
            if (queryFields != null)
            {
                for (Int32 i = 0; i < queryFields.Length; i++)
                {
                    this._queryFields.Add(SqlQueryField.InternalCreateFromColumn(queryFields[i]));
                }
            }

            return(this);
        }
        /// <summary>
        /// 查询指定函数语句并返回当前语句
        /// </summary>
        /// <param name="function">函数</param>
        /// <param name="aliasesName">别名</param>
        /// <exception cref="ArgumentNullException">函数不能为空</exception>
        /// <returns>当前语句</returns>
        public SelectCommand Query(ISqlFunction function, String aliasesName)
        {
            if (function == null)
            {
                throw new ArgumentNullException("function");
            }

            this._queryFields.Add(SqlQueryField.InternalCreateFromFunction(function.ToString(this.DatabaseType), aliasesName));

            if (function.HasParameters)
            {
                this._parameters.AddRange(function.GetAllParameters());
            }

            return(this);
        }
        /// <summary>
        /// 查询插入最后一条记录的ID并返回当前语句
        /// </summary>
        /// <exception cref="DatabaseNotSupportException">Oracle数据库不支持获取最后一条记录的ID</exception>
        /// <returns>当前语句</returns>
        public SelectCommand QueryIdentity()
        {
            if (this.DatabaseType == DatabaseType.SQLite)
            {
                this._queryFields.Add(SqlQueryField.InternalCreateFromFunction("LAST_INSERT_ROWID()"));
            }
            else if (this.DatabaseType == DatabaseType.Oracle)
            {
                throw new DatabaseNotSupportException("Oracle database does not support identity.");
            }
            else
            {
                this._queryFields.Add(SqlQueryField.InternalCreateFromFunction("@@IDENTITY"));
            }

            return(this);
        }
        /// <summary>
        /// 查询指定选择语句并返回当前语句
        /// </summary>
        /// <param name="command">选择语句</param>
        /// <param name="aliasesName">别名</param>
        /// <exception cref="ArgumentNullException">选择语句不能为空</exception>
        /// <returns>当前语句</returns>
        public SelectCommand Query(SelectCommand command, String aliasesName)
        {
            if (command == null)
            {
                throw new ArgumentNullException("function");
            }

            this._queryFields.Add(SqlQueryField.InternalCreateFromFunction(command.ToString(true), aliasesName));

            List <SqlParameter> parameters = command.GetAllParameters();

            if (parameters != null)
            {
                this._parameters.AddRange(parameters);
            }

            return(this);
        }
        /// <summary>
        /// 判断两个Sql查询字段是否相同
        /// </summary>
        /// <param name="obj">待比较的Sql查询字段</param>
        /// <returns>两个Sql查询字段是否相同</returns>
        public override Boolean Equals(Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            SqlQueryField queryField = obj as SqlQueryField;

            if (queryField == null)
            {
                return(false);
            }

            if (!String.Equals(this._tableName, queryField._tableName))
            {
                return(false);
            }

            if (!String.Equals(this._columnName, queryField._columnName))
            {
                return(false);
            }

            if (!String.Equals(this._aliasesName, queryField._aliasesName))
            {
                return(false);
            }

            if (_useFunction != queryField._useFunction)
            {
                return(false);
            }

            if (!String.Equals(this._function, queryField._function))
            {
                return(false);
            }

            return(true);
        }
 /// <summary>
 /// 查询指定合计函数并返回当前语句
 /// </summary>
 /// <param name="function">合计函数类型</param>
 /// <returns>当前语句</returns>
 public SelectCommand Query(SqlAggregateFunction function)
 {
     this._queryFields.Add(SqlQueryField.InternalCreateFromAggregateFunction(function));
     return(this);
 }
 /// <summary>
 /// 查询指定合计函数并返回当前语句
 /// </summary>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数类型</param>
 /// <param name="fieldName">要查询的字段名</param>
 /// <returns>当前语句</returns>
 public SelectCommand Query(String tableName, SqlAggregateFunction function, String fieldName)
 {
     this._queryFields.Add(SqlQueryField.InternalCreateFromAggregateFunction(tableName, function, fieldName));
     return(this);
 }
 /// <summary>
 /// 查询指定字段名并返回当前语句
 /// </summary>
 /// <param name="queryField">要查询的字段名</param>
 /// <returns>当前语句</returns>
 public SelectCommand Query(String queryField)
 {
     this._queryFields.Add(SqlQueryField.InternalCreateFromColumn(queryField));
     return(this);
 }
 /// <summary>
 /// 查询指定字段名并返回当前语句
 /// </summary>
 /// <param name="tableName">表格名称</param>
 /// <param name="queryField">要查询的字段名</param>
 /// <param name="aliasesName">字段名的别名</param>
 /// <returns>当前语句</returns>
 public SelectCommand Query(String tableName, String queryField, String aliasesName)
 {
     this._queryFields.Add(SqlQueryField.InternalCreateFromColumn(tableName, queryField, aliasesName));
     return(this);
 }