Example #1
0
        protected virtual string GetDeleteSql(SqlQuery query)
        {
            StringBuilder buf = new StringBuilder("delete from ");

            if (schema != null && schema.Length > 0)
            {
                buf.Append("[").Append(schema).Append("].");
            }
            buf.Append("[").Append(name).Append("]");
            if (query != null)
            {
                buf.Append(" ").Append(query.GetSql(this));
            }
            buf.Append(";");
            return(buf.ToString());
        }
 public virtual string GetSql(SqlTable table, ref int offset)
 {
     if (HasQuery)
     {
         string sql = query.GetSql(table, ref offset);
         return(string.Format("({0})", sql));
     }
     else
     {
         index  = offset;
         offset = offset + 1;
         string name = table.Translate(column);
         if (name == null || name.Length == 0)
         {
             //name = column;
             throw new LightException(string.Format("column {0} not found in table {1}", column, table.Name));
         }
         return(string.Format("[{0}]{1}@{2}", name, oper, index));
     }
 }
Example #3
0
 protected virtual string GetSelectSql(SqlQuery query)
 {
     if (selectSQL == null)
     {
         StringBuilder buf   = new StringBuilder("select ");
         bool          comma = false;
         foreach (SqlColumn column in columns)
         {
             if (comma)
             {
                 buf.Append(",");
             }
             else
             {
                 comma = true;
             }
             buf.Append("[").Append(column.Name).Append("]");
         }
         buf.Append(" from ");
         if (schema != null && schema.Length > 0)
         {
             buf.Append("[").Append(schema).Append("].");
         }
         buf.Append("[").Append(name).Append("]");
         selectSQL = buf.ToString();
     }
     if (query != null)
     {
         StringBuilder buf = new StringBuilder(selectSQL);
         buf.Append(" ").Append(query.GetSql(this));
         buf.Append(";");
         return(buf.ToString());
     }
     else
     {
         return(string.Format("{0};", selectSQL));
     }
 }
Example #4
0
		protected virtual string GetSelectSql(SqlQuery query)
		{
			if (selectSQL == null)
			{
				StringBuilder buf = new StringBuilder("select ");
				bool comma = false;
				foreach (SqlColumn column in columns)
				{
					if (comma)
						buf.Append(",");
					else
						comma = true;
					buf.Append("[").Append(column.Name).Append("]");
				}
				buf.Append(" from ");
				if (schema != null && schema.Length > 0)
					buf.Append("[").Append(schema).Append("].");
				buf.Append("[").Append(name).Append("]");
				selectSQL = buf.ToString();
			}
			if (query != null)
			{
				StringBuilder buf = new StringBuilder(selectSQL);
				buf.Append(" ").Append(query.GetSql(this));
				buf.Append(";");
				return buf.ToString();
			}
			else
				return string.Format("{0};", selectSQL);
		}
Example #5
0
		protected virtual string GetDeleteSql(SqlQuery query)
		{
			StringBuilder buf = new StringBuilder("delete from ");
			if (schema != null && schema.Length > 0)
				buf.Append("[").Append(schema).Append("].");
			buf.Append("[").Append(name).Append("]");
			if (query != null)
				buf.Append(" ").Append(query.GetSql(this));
			buf.Append(";");
			return buf.ToString();
		}