internal override StringBuilder AsEsql(StringBuilder builder, bool isTopLevel, int indentLevel) { // The SELECT/DISTINCT part. StringUtil.IndentNewLine(builder, indentLevel); builder.Append("SELECT "); if (m_selectDistinct == CellQuery.SelectDistinct.Yes) { builder.Append("DISTINCT "); } GenerateProjectionEsql(builder, m_nodeTableAlias, true, indentLevel, isTopLevel); // Get the FROM part. builder.Append("FROM "); CqlWriter.AppendEscapedQualifiedName(builder, m_extent.EntityContainer.Name, m_extent.Name); builder.Append(" AS ").Append(m_nodeTableAlias); // Get the WHERE part only when the expression is not simply TRUE. if (!BoolExpression.EqualityComparer.Equals(WhereClause, BoolExpression.True)) { StringUtil.IndentNewLine(builder, indentLevel); builder.Append("WHERE "); WhereClause.AsEsql(builder, m_nodeTableAlias); } return(builder); }
internal override StringBuilder AsEsql(StringBuilder builder, bool isTopLevel, int indentLevel) { // The SELECT part StringUtil.IndentNewLine(builder, indentLevel); builder.Append("SELECT "); if (isTopLevel) { builder.Append("VALUE "); } Debug.Assert(m_caseSlotInfo.OutputMember != null, "We only construct member slots, not boolean slots."); builder.Append("-- Constructing ").Append(m_caseSlotInfo.OutputMember.LeafName); Debug.Assert(Children.Count == 1, "CaseCqlBlock can have exactly one child."); var childBlock = Children[0]; base.GenerateProjectionEsql(builder, childBlock.CqlAlias, true, indentLevel, isTopLevel); // The FROM part: FROM (ChildView) AS AliasName builder.Append("FROM ("); childBlock.AsEsql(builder, false, indentLevel + 1); StringUtil.IndentNewLine(builder, indentLevel); builder.Append(") AS ").Append(childBlock.CqlAlias); // Get the WHERE part only when the expression is not simply TRUE. if (false == BoolExpression.EqualityComparer.Equals(WhereClause, BoolExpression.True)) { StringUtil.IndentNewLine(builder, indentLevel); builder.Append("WHERE "); WhereClause.AsEsql(builder, childBlock.CqlAlias); } return(builder); }