private void LinkNotEqualVar(string[] condition, Variable _var1, Variable _var2, Variable _var3) { Variable var1 = new Variable(); if (condition[0] == "$1") { var1 = _var1; } else if (condition[0] == "$2") { var1 = _var2; } else if (condition[0] == "$3") { var1 = _var3; } else { var1 = new Variable().Set(condition[0]); } Variable var2 = new Variable(); if (condition[1] == "$1") { var2 = _var1; } else if (condition[1] == "$2") { var2 = _var2; } else if (condition[1] == "$3") { var2 = _var3; } else { var2 = new Variable().Set(condition[1]); } var newCondition = new NotEqualCondition(var1, var2); conditions.Add(newCondition as ICondition); }
private void LinkNotEqualVar(string[] condition, Ray _var1, Ray _var2, Ray _var3) { Ray var1 = new Ray(); if (condition[0] == "$1") { var1 = _var1; } else if (condition[0] == "$2") { var1 = _var2; } else if (condition[0] == "$3") { var1 = _var3; } else { var1 = new Ray().Set(condition[0]); } Ray var2 = new Ray(); if (condition[1] == "$1") { var2 = _var1; } else if (condition[1] == "$2") { var2 = _var2; } else if (condition[1] == "$3") { var2 = _var3; } else { var2 = new Ray().Set(condition[1]); } var newCondition = new NotEqualCondition(var1, var2); conditions.Add(newCondition as ICondition); }
/// <summary> /// 不等于条件解析;如果条件的值为空,则字段的空字符串和NULL值都排除 /// </summary> /// <param name="condition">需要解析的条件对象</param> /// <returns>返回解析后的条件字符串</returns> protected override string NotEqualParse(NotEqualCondition condition) { StringBuilder conditionStr = new StringBuilder(" "); string queryColName = condition.SearchColumn.CurrentSearcher.TableName + "." + condition.SearchColumn.ColumnName; if (string.IsNullOrEmpty(condition.SearchColumn.ConditionString)) { conditionStr.Append(queryColName); } else { conditionStr.Append(condition.SearchColumn.ConditionString.Replace(SQLPlaceholder.ColName, queryColName)); } conditionStr.Append(" <> "); if (condition.ParamValue is SearchColumn) { SearchColumn tmpColumn = (SearchColumn)condition.ParamValue; string valueColName = tmpColumn.CurrentSearcher.TableName + "." + tmpColumn.ColumnName; conditionStr.Append(valueColName); } else { if (condition.ParamValue != null && !string.IsNullOrEmpty(condition.ParamValue.ToString())) { string paramName = "P" + Guid.NewGuid().ToString().ToLower().Replace("-", ""); conditionStr.Append("@" + paramName); ParamCollection.Add(new MySqlParameter(paramName, condition.ParamValue)); } else { conditionStr.Insert(0, " ("); conditionStr.Append("'' "); conditionStr.Append(" OR "); conditionStr.Append(queryColName); conditionStr.Append(" IS NOT NULL) "); } } conditionStr.Append(" "); return(conditionStr.ToString()); }
/// <summary> /// 不等于条件解析;如果条件的值为空,则字段的空字符串和NULL值都排除 /// </summary> /// <param name="condition">需要解析的条件对象</param> /// <returns>返回解析后的条件字符串</returns> protected override string NotEqualParse(NotEqualCondition condition) { StringBuilder conditionStr = new StringBuilder(" "); string queryColName = condition.SearchColumn.CurrentSearcher.TableName + "." + condition.SearchColumn.ColumnName; if (string.IsNullOrEmpty(condition.SearchColumn.ConditionString)) { conditionStr.Append(queryColName); } else { conditionStr.Append(condition.SearchColumn.ConditionString.Replace(SQLPlaceholder.ColName, queryColName)); } conditionStr.Append(" <> "); if (condition.ParamValue is SearchColumn) { SearchColumn tmpColumn = (SearchColumn)condition.ParamValue; string valueColName = tmpColumn.CurrentSearcher.TableName + "." + tmpColumn.ColumnName; conditionStr.Append(valueColName); } else { if (condition.ParamValue != null && !string.IsNullOrEmpty(condition.ParamValue.ToString())) { string paramName = "P" + Guid.NewGuid().ToString().ToLower().Replace("-", ""); conditionStr.Append(":" + paramName); ParamCollection.Add(new DBParam(paramName, condition.ParamValue)); } else { conditionStr.Insert(0, " ("); conditionStr.Append("'' "); conditionStr.Append(" OR "); conditionStr.Append(queryColName); conditionStr.Append(" IS NOT NULL) "); } } conditionStr.Append(" "); return conditionStr.ToString(); }
/// <summary> /// 不等于条件 /// </summary> /// <param name="relation">条件关系</param> /// <param name="column">查询字段对象</param> /// <param name="paramVal">比较的值</param> /// <returns>返回不等于条件对象</returns> public static NotEqualCondition NotEqual(ConditionRelation relation, SearchColumn column, object paramVal) { NotEqualCondition cond = new NotEqualCondition(relation, column, paramVal); return cond; }
/// <summary> /// 不等于条件 /// </summary> /// <param name="column">查询字段对象</param> /// <param name="paramVal">比较的值</param> /// <returns>返回不等于条件对象</returns> public static NotEqualCondition NotEqual(SearchColumn column, object paramVal) { NotEqualCondition cond = new NotEqualCondition(column, paramVal); return cond; }
/// <summary> /// 不等于条件 /// </summary> /// <param name="paramVal">比较的值</param> /// <returns>返回不等于条件对象</returns> public static NotEqualCondition NotEqual(object paramVal) { NotEqualCondition cond = new NotEqualCondition(paramVal); return cond; }
public void Test() { var condition = new NotEqualCondition("Name", "@Name"); Assert.Equal("Name<>@Name", condition.GetCondition()); }
/// <summary> /// 不等于条件 /// </summary> /// <param name="relation">条件关系</param> /// <param name="column">查询字段对象</param> /// <param name="paramVal">比较的值</param> /// <returns>返回不等于条件对象</returns> public static NotEqualCondition NotEqual(ConditionRelation relation, SearchColumn column, object paramVal) { NotEqualCondition cond = new NotEqualCondition(relation, column, paramVal); return(cond); }
/// <summary> /// 不等于条件 /// </summary> /// <param name="paramVal">比较的值</param> /// <returns>返回不等于条件对象</returns> public static NotEqualCondition NotEqual(object paramVal) { NotEqualCondition cond = new NotEqualCondition(paramVal); return(cond); }