/// <summary> /// todo:optimize /// </summary> /// <param name="table"></param> /// <param name="openQuote"></param> /// <param name="closeQuote"></param> /// <param name="offset"></param> /// <returns></returns> public override String GetSql(SqlTable table, Char openQuote, Char closeQuote, ref Int32 offset) { String name = table.Translate(Column); if (String.IsNullOrEmpty(name)) { throw new DalException(String.Format("Column {0} not found in table {1}", Column, table.Name)); } index = offset; IList values = (IList)Value; StringBuilder buf = new StringBuilder(); buf.Append(openQuote).Append(name).Append(closeQuote).Append(" ").Append(Operator).Append(" ("); if (values.Count > 0) { offset = offset + values.Count; for (Int32 i = index; i < offset; i++) { if (i > index) { buf.Append(","); } buf.Append(String.Format("@{0}", i)); } } else { buf.Append("null"); } buf.Append(")"); return(buf.ToString()); }
public override String GetSql(SqlTable table, Char openQuote, Char closeQuote, ref Int32 offset) { var name = table.Translate(Column); if (String.IsNullOrEmpty(name)) { throw new DalException(String.Format("Table {0} doesn't contain column {1}.", table.Name, Column)); } index = offset; offset++; return(String.Format(openQuote + "{0}" + closeQuote + " {1} null", name, Operator)); }
public String GetSql(SqlTable table, Char openQuote, Char closeQuote) { String name = table.Translate(Column); if (String.IsNullOrEmpty(name)) { throw new DalException(String.Format("Table {0} does not contain attribute {1}.", table.Name, Column)); } String dir = Ascending ? "asc" : "desc"; StringBuilder buf = new StringBuilder(); buf.Append(openQuote).Append(name).Append(closeQuote); return(string.Format("{0} {1}", buf, dir)); }
/// <summary> /// /// </summary> /// <param name="table"></param> /// <param name="openQuote"></param> /// <param name="closeQuote"></param> /// <param name="offset"></param> /// <returns></returns> public virtual String GetSql(SqlTable table, Char openQuote, Char closeQuote, ref Int32 offset) { if (!String.IsNullOrEmpty(Symbol)) { return(String.Format("{0}", Symbol)); } if (HasQuery) { String sql = query.GetQuerySql(table, openQuote, closeQuote, ref offset); return(String.Format("({0})", sql)); } else { index = offset; offset += 1; String name = table.Translate(column); if (String.IsNullOrEmpty(name)) { throw new DalException(String.Format("Table {0} does not contain attribute {1}.", table.Name, column)); } String result; if (op.ToUpper().IndexOf(Between, StringComparison.Ordinal) > -1) { index2 = index + 1; result = String.Format("{0}{1}{2} {3} @{4} AND @{5}", openQuote, name, closeQuote, op, index, index2); offset++; } else { result = String.Format(openQuote + "{0}" + closeQuote + "{1}@{2}", name, op, index); } return(result); } }