示例#1
0
        private string CreateStatSql()
        {
            StringBuilder sql          = new StringBuilder("SELECT ");
            bool          appendBefore = false;
            bool          subAfter     = false;

            for (int i = 0; i < fStatFields.Count; ++i)
            {
                StatFieldConfigItem field = fStatFields[i];
                string nickName           = field.NickName;
                string fieldName          = Context.EscapeName(MainResolver.GetFieldInfo(nickName).FieldName);

                if (appendBefore)
                {
                    sql.Append(",");
                }
                switch (field.Method)
                {
                case StatMethod.Count:
                    appendBefore = false;
                    subAfter     = true;
                    break;

                default:
                    sql.AppendFormat("{0}({1}) {2}", field.Method, fieldName, nickName);
                    appendBefore = true;
                    subAfter     = false;
                    break;
                }
            }
            if (subAfter)
            {
                sql = sql.Remove(sql.Length - 1, 1);
            }
            sql.Append(" FROM ").Append(GetTableName(Context));
            return(sql.ToString());
        }