コード例 #1
0
        public IQuery Order(string column, bool asc)
        {
            LitOrder o = new LitOrder(column, asc);

            orders.Add(o);
            return(this);
        }
コード例 #2
0
        public virtual string GetSql(LitTable 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);
                }
                LitConstraint 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(",");
                    }
                    LitOrder order = orders[i];
                    string   sql   = order.GetSql(table);
                    buf.Append(sql);
                }
            }
            return(buf.ToString());
        }
コード例 #3
0
 public IQuery Order(string column, bool asc)
 {
     LitOrder o = new LitOrder(column, asc);
     orders.Add(o);
     return this;
 }