/// <summary> /// 转换成SQL语句 /// </summary> /// <returns>SQL语句</returns> public override string ToSQL() { if (ChildCollection.Count == 0) { return(string.Empty); } var condition = new StringBuilder(ChildCollection.Count * 56); for (int i = 0; i < ChildCollection.Count; i++) { if (ChildCollection[i] == null) { continue; } if (ChildCollection[i] is ConditionStatement) { var subCondition = ChildCollection[i] as ConditionStatement; if (subCondition == null) { continue; } if (i == 0) { condition.Append(subCondition.ToSQL()); } else { if (subCondition.LogicalOperator == OperatorType.And) { condition.Append(And.Clause(subCondition.ToSQL())); } else { condition.Append(Or.Clause(subCondition.ToSQL())); } } } else //SqlPrimaryKey { condition.Append(ChildCollection[i].ToSQL()); } } return(condition.ToString()); }
/// <summary> /// 转换成SQL语句 /// </summary> /// <returns>SQL语句</returns> public override string ToSQL() { if (ChildCollection.Count == 0) { return(string.Empty); } var condition = new StringBuilder(ChildCollection.Count * 56); for (int i = 0; i < ChildCollection.Count; i++) { var subCondition = ChildCollection[i] as ConditionStatement; if (subCondition == null) { continue; } if (i == 0) { condition.Append(subCondition.ToSQL()); } else { if (subCondition.RelationOperator == OperatorType.And) { condition.Append(And.Clause(subCondition.ToSQL())); } else { condition.Append(Or.Clause(subCondition.ToSQL())); } } } this.ConditionString = condition.ToString(); return(base.ToSQL()); }