public virtual string SerializeCaseExpressionCase(SQLCaseExpression.Case expressionCase) { return "WHEN " + expressionCase.WhenCondition.SQL(this) + " THEN " + expressionCase.Result.SQL(this); }
public virtual string SerializeCaseExpression(SQLCaseExpression expression) { if (expression.Cases.Count() == 0) throw new InvalidOperationException("There are no cases for the CASE statement"); var tokens = new TokenSerializer(); tokens.Add("CASE"); if (expression.InputExpression != null) tokens.Add(expression.InputExpression.SQL(this)); var cases = string.Join(" ", expression.Cases.Select(objCase => SerializeCaseExpressionCase(objCase)).ToArray()); tokens.Add(cases); if (expression.ElseResult != null) { tokens.Add("ELSE"); tokens.Add(expression.ElseResult.SQL(this)); } tokens.Add("END"); return tokens.ToString(); }