Example #1
0
        public virtual string GetSql(SqlTable table, ref int offset)
        {
            if (!IsComplete)
            {
                throw new InvalidOperationException("invalid query");
            }

            StringBuilder buf = new StringBuilder();
            int           sz  = constraints.Count;

            if (sz > 0)
            {
                buf.Append("where");
            }
            for (int i = 0; i < sz; i++)
            {
                if (i > 0)
                {
                    string op = operators[i - 1];
                    buf.Append(" ").Append(op);
                }
                SqlConstraint constraint = constraints[i];
                string        sql        = constraint.GetSql(table, ref offset);
                buf.Append(" ").Append(sql);
            }
            sz = orders.Count;
            if (sz > 0)
            {
                buf.Append(" order by ");
                for (int i = 0; i < sz; i++)
                {
                    if (i > 0)
                    {
                        buf.Append(",");
                    }
                    SqlOrder order = orders[i];
                    string   sql   = order.GetSql(table);
                    buf.Append(sql);
                }
            }
            return(buf.ToString());
        }
Example #2
0
        protected void AddConstraint(string op, object val)
        {
            SqlConstraint c = new SqlConstraint(pending, op, val);

            AddConstraint(c);
        }
Example #3
0
		protected void AddConstraint(SqlConstraint c)
		{
			ErrorIfNotPending();
			constraints.Add(c);
			pending = null;
		}
Example #4
0
 protected void AddConstraint(SqlConstraint c)
 {
     ErrorIfNotPending();
     constraints.Add(c);
     pending = null;
 }
Example #5
0
		protected void AddConstraint(string op, object val)
		{
			SqlConstraint c = new SqlConstraint(pending, op, val);
			AddConstraint(c);
		}