예제 #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());
        }
예제 #2
0
        protected void AddConstraint(string op, object val)
        {
            SqlConstraint c = new SqlConstraint(pending, op, val);

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