public void Add(DBTable table, String sField, DBValue value, SQLConditionType type) { if (table.m_fields.ContainsKey(sField)) { String sValue = String.Empty; switch (table.m_fields[sField].Type) { case DBField.cTypeInt: sValue = value; break; case DBField.cTypeString: if (type == SQLConditionType.Like || type == SQLConditionType.NotLike) { sValue = "'%" + ((String)value).Replace("'", "''") + "%'"; } else { sValue = "'" + ((String)value).Replace("'", "''") + "'"; } break; } AddCustom(table.m_tableName + "." + sField, sValue, type); } }
public void AddCustom(string what, string value, SQLConditionType type) { String sType = String.Empty; switch (type) { case SQLConditionType.Equal: sType = " = "; break; case SQLConditionType.NotEqual: sType = " != "; break; case SQLConditionType.LessThan: sType = " < "; break; case SQLConditionType.LessEqualThan: sType = " <= "; break; case SQLConditionType.GreaterThan: sType = " > "; break; case SQLConditionType.GreaterEqualThan: sType = " >= "; break; case SQLConditionType.Like: sType = " like "; break; case SQLConditionType.NotLike: sType = " not like "; break; case SQLConditionType.In: sType = " in "; break; case SQLConditionType.NotIn: sType = " not in "; break; } if (SQLConditionType.In == type || SQLConditionType.NotIn == type) // reverse { AddCustom(value + sType + "(" + what + ")"); } else { AddCustom(what + sType + value); } }
public void AddCustom(string what, string value, SQLConditionType type, bool EncloseIfString) { if (EncloseIfString) { if (value.Length > 2 && value[0] != '\'' && !value.IsNumerical()) { value = "'" + value + "'"; } } AddCustom(what, value, type); }
private SQLCondition(string column, SQLOperator op, SQLConditionType conditionType = SQLConditionType.None) { string sqlOperator = ""; switch (op) { case SQLOperator.Equal: sqlOperator = "="; break; case SQLOperator.NEqual: sqlOperator = "<>"; break; case SQLOperator.Greater: sqlOperator = ">"; break; case SQLOperator.Lesser: sqlOperator = "<"; break; case SQLOperator.GEqual: sqlOperator = ">="; break; case SQLOperator.LEqual: sqlOperator = "<="; break; case SQLOperator.Between: sqlOperator = "BETWEEN"; break; case SQLOperator.Like: sqlOperator = "LIKE"; break; case SQLOperator.In: sqlOperator = "IN"; break; default: break; } switch (conditionType) { case SQLConditionType.None: ConditionType = ""; break; case SQLConditionType.And: ConditionType = "AND"; break; case SQLConditionType.Or: ConditionType = "OR"; break; default: ConditionType = ""; break; } Condition = column + sqlOperator; }
public void AddSubQuery(string field, DBTable table, SQLCondition innerConditions, DBValue value, SQLConditionType type) { string sValue; if (type == SQLConditionType.Like || type == SQLConditionType.NotLike) sValue = "'%" + ((String)value).Replace("'", "''") + "%'"; else sValue = ((String)value).Replace("'", "''"); AddCustom("( select " + field + " from " + table.m_tableName + innerConditions + innerConditions.orderString + innerConditions.limitString + " ) ", sValue, type); }
public SQLCondition(DBTable table, String sField, DBValue value, SQLConditionType type) { Add(table, sField, value, type); }
public void AddCustom(string what, string value, SQLConditionType type) { String sType = String.Empty; switch (type) { case SQLConditionType.Equal: sType = " = "; break; case SQLConditionType.NotEqual: sType = " != "; break; case SQLConditionType.LessThan: sType = " < "; break; case SQLConditionType.LessEqualThan: sType = " <= "; break; case SQLConditionType.GreaterThan: sType = " > "; break; case SQLConditionType.GreaterEqualThan: sType = " >= "; break; case SQLConditionType.Like: sType = " like "; break; case SQLConditionType.NotLike: sType = " not like "; break; case SQLConditionType.In: sType = " in "; break; case SQLConditionType.NotIn: sType = " not in "; break; } if (SQLConditionType.In == type || SQLConditionType.NotIn == type) // reverse AddCustom(value + sType + "(" + what + ")"); else AddCustom(what + sType + value); }
public void AddCustom(string what, string value, SQLConditionType type, bool EncloseIfString) { if (EncloseIfString) { if (value.Length > 2 && value[0] != '\'' && !value.IsNumerical()) value = "'" + value + "'"; } AddCustom(what, value, type); }
public void Add(DBTable table, String sField, DBValue value, SQLConditionType type) { if (table.m_fields.ContainsKey(sField)) { String sValue = String.Empty; switch (table.m_fields[sField].Type) { case DBField.cTypeInt: sValue = value; break; case DBField.cTypeString: if (type == SQLConditionType.Like || type == SQLConditionType.NotLike) sValue = "'%" + ((String)value).Replace("'", "''") + "%'"; else sValue = "'" + ((String)value).Replace("'", "''") + "'"; break; } AddCustom(table.m_tableName + "." + sField, sValue, type); } }
public SQLCondition(string column, SQLOperator op, int value, SQLConditionType conditionType = SQLConditionType.None) : this(column, op, conditionType) { Condition += value; }
public SQLCondition(string column, SQLOperator op, string value, SQLConditionType conditionType = SQLConditionType.None) : this(column, op, conditionType) { Condition += "'" + value + "'"; }
public void AddSubQuery(string field, DBTable table, SQLCondition innerConditions, DBValue value, SQLConditionType type) { string sValue; if (type == SQLConditionType.Like || type == SQLConditionType.NotLike) { sValue = "'%" + ((String)value).Replace("'", "''") + "%'"; } else { sValue = ((String)value).Replace("'", "''"); } AddCustom("( select " + field + " from " + table.m_tableName + innerConditions + innerConditions.orderString + innerConditions.limitString + " ) ", sValue, type); }