/// <summary> /// add where condition with RelationShip /// </summary> /// <param name="Relation"></param> /// <param name="ColumnName"></param> /// <param name="Comparison"></param> /// <param name="ColumnName"></param> public void AddWhereByRelationShip(WhereRelation Relation, String LeftColumnName, CommandComparison Comparison, String RightColumnName) { if (String.IsNullOrEmpty(LeftColumnName) || String.IsNullOrEmpty(RightColumnName)) { throw new Exception("Cloumn name is null."); } condition.Add(String.Format(" {0} {1} {2} {3}", CommonService.GetWhereRelation(Relation), LeftColumnName, CommonService.ConvertComparison(Comparison), RightColumnName)); }
/// <summary> /// add where condition with select query /// </summary> /// <param name="Relation"></param> /// <param name="ColumnName"></param> /// <param name="Comparison"></param> /// <param name="SelectCommand"></param> public void AddWhereBySelect(WhereRelation Relation, String ColumnName, CommandComparison Comparison, String SelectCommand) { if (String.IsNullOrEmpty(ColumnName)) { throw new Exception("ColumnName is null."); } condition.Add(String.Format(" {0} {1} {2} ({3})", CommonService.GetWhereRelation(Relation), ColumnName, CommonService.ConvertComparison(Comparison), SelectCommand)); }
/// <summary> /// add where condition with between /// </summary> /// <param name="Relation"></param> /// <param name="ColumnName"></param> /// <param name="Comparison"></param> /// <param name="value1"></param> /// <param name="value2"></param> public void AddWhere(WhereRelation Relation, String ColumnName, CommandComparison Comparison, object value1, object value2) { String Condition; if (String.IsNullOrEmpty(ColumnName)) { throw new Exception("Values is null."); } if (!(Comparison == CommandComparison.Between || Comparison == CommandComparison.NotBetween)) { throw new Exception("only support Between comparison."); } if (CommonService.CheckValueType(value1)) { Condition = String.Format(" {0} {1} {2} {3}", CommonService.GetWhereRelation(Relation), ColumnName, CommonService.ConvertComparison(Comparison), "'" + value1 + "'"); } else { Condition = String.Format(" {0} {1} {2} {3}", CommonService.GetWhereRelation(Relation), ColumnName, CommonService.ConvertComparison(Comparison), value1); } if (CommonService.CheckValueType(value2)) { Condition += " and '" + value2 + "'"; } else { Condition += " and " + value2; } condition.Add(Condition); }
/// <summary> /// add where condition /// </summary> /// <param name="Relation"></param> /// <param name="ColumnName"></param> /// <param name="Comparison"></param> /// <param name="value"></param> public void AddWhere(WhereRelation Relation, String ColumnName, CommandComparison Comparison, object value) { if (String.IsNullOrEmpty(ColumnName)) { throw new Exception("Values is null."); } if (CommonService.CheckValueType(value)) { condition.Add(String.Format(" {0} {1} {2} {3}", CommonService.GetWhereRelation(Relation), ColumnName, CommonService.ConvertComparison(Comparison), "'" + value + "'")); } else { condition.Add(String.Format(" {0} {1} {2} {3}", CommonService.GetWhereRelation(Relation), ColumnName, CommonService.ConvertComparison(Comparison), value)); } }
/// <summary> /// add where condition with list /// </summary> /// <param name="Relation"></param> /// <param name="ColumnName"></param> /// <param name="Comparison"></param> /// <param name="Value"></param> public void AddWhere(WhereRelation Relation, String ColumnName, CommandComparison Comparison, object[] Value) { String Condition; if (String.IsNullOrEmpty(ColumnName)) { throw new Exception("Values is null."); } if (!(Comparison == CommandComparison.In || Comparison == CommandComparison.NotIn)) { throw new Exception("only support In comparison."); } Condition = "("; foreach (object value in Value) { if (CommonService.CheckValueType(value)) { Condition = Condition + "'" + value + "',"; } else { Condition = Condition + value + ","; } } Condition += ")"; Condition = Condition.Replace(",)", ")"); condition.Add(String.Format(" {0} {1} {2} {3}", CommonService.GetWhereRelation(Relation), ColumnName, CommonService.ConvertComparison(Comparison), Condition)); }