Exemple #1
0
        /// <summary>
        /// Prepare the main statement body
        /// </summary>
        protected virtual string PrepareMainStatement(CSqlField.QryFlag stmtFlag)
        {
            string query = "";

            foreach (KeyValuePair <string, CSqlField> field in m_sqlRow)
            {
                if ((field.Value.Flag & stmtFlag) == 0)
                {
                    continue;
                }
                if (query.Length > 0)
                {
                    query += ", ";
                }
                query += field.Value.Column;
            }
            return(query);
        }
Exemple #2
0
        /// <summary>
        /// Prepare a WHERE condition string
        /// </summary>
        /// <returns>Constructed query condition. If pre-defined condition string exists, return advanced condition string</returns>
        protected virtual string PrepareWhereStatement(CSqlField.QryFlag whereFlag)
        {
            if (m_selectCondition.Length > 0)
            {
                return(PrepareAdvancedWhereStatement());
            }
            string whereCondition = "";

            foreach (KeyValuePair <string, CSqlField> field in m_sqlRow)
            {
                if ((field.Value.Flag & whereFlag) == 0 || field.Value.IsNull())
                {
                    continue;
                }
                if (whereCondition.Length > 0)
                {
                    whereCondition += " AND ";
                }
                whereCondition += field.Value.Column;
                whereCondition += " = ";
                if (field.Value.Type == TypeCode.String)
                {
                    string literal = StringToLiteral(field.Value.String);
                    whereCondition += literal;
                }
                else if (field.Value.Type == TypeCode.Double)
                {
                    whereCondition += field.Value.Double;
                }
                else // Bool fields are 0/1
                {
                    whereCondition += field.Value.Integer;
                }
            }
            return(whereCondition);
        }