src/Shared/EntityFramework/Core/Mapping/ViewGeneration/Structures/CaseStatement.cs
// <summary>
// Generates eSQL for the current <see cref="CaseStatement" />.
// </summary>
Generates eSQL for the current .
Generates eSQL for the current .
internal StringBuilder AsEsql(
            StringBuilder builder, IEnumerable<WithRelationship> withRelationships, string blockAlias, int indentLevel)
        {
            if (Clauses.Count == 0)
            {
                Debug.Assert(ElseValue != null, "CASE statement with no WHEN/THENs must have ELSE.");
                CaseSlotValueAsEsql(builder, ElseValue, MemberPath, blockAlias, withRelationships, indentLevel);
                return builder;
            }
            builder.Append("CASE");
            foreach (var clause in Clauses)
            {
                StringUtil.IndentNewLine(builder, indentLevel + 2);
                builder.Append("WHEN ");
                clause.Condition.AsEsql(builder, blockAlias);
                builder.Append(" THEN ");
                CaseSlotValueAsEsql(builder, clause.Value, MemberPath, blockAlias, withRelationships, indentLevel + 2);
            }
            if (ElseValue != null)
            {
                StringUtil.IndentNewLine(builder, indentLevel + 2);
                builder.Append("ELSE ");
                CaseSlotValueAsEsql(builder, ElseValue, MemberPath, blockAlias, withRelationships, indentLevel + 2);
            }
            StringUtil.IndentNewLine(builder, indentLevel + 1);
            builder.Append("END");
            return builder;
        }
internal StringBuilder AsEsql ( StringBuilder builder , IEnumerable < WithRelationship > withRelationships , string blockAlias , int indentLevel ) { if ( Clauses . Count == 0 ) { Debug . Assert ( ElseValue != null , " " ) ; CaseSlotValueAsEsql ( builder , ElseValue , MemberPath , blockAlias , withRelationships , indentLevel ) ; return builder ; } builder . Append ( " " ) ; foreach ( var clause in Clauses ) { StringUtil . IndentNewLine ( builder , indentLevel + 2 ) ; builder . Append ( " " ) ; clause . Condition . AsEsql ( builder , blockAlias ) ; builder . Append ( " " ) ; CaseSlotValueAsEsql ( builder , clause . Value , MemberPath , blockAlias , withRelationships , indentLevel + 2 ) ; } if ( ElseValue != null ) { StringUtil . IndentNewLine ( builder , indentLevel + 2 ) ; builder . Append ( " " ) ; CaseSlotValueAsEsql ( builder , ElseValue , MemberPath , blockAlias , withRelationships , indentLevel + 2 ) ; } StringUtil . IndentNewLine ( builder , indentLevel + 1 ) ; builder . Append ( " " ) ; return builder ; }
Generates eSQL for the current .
Generates eSQL for the current .
// This is just a single ELSE: no condition at all. // Generate the Case WHEN .. THEN ..., WHEN ... THEN ..., END
builder
StringBuilder
withRelationships
IEnumerable<WithRelationship>
blockAlias
string
indentLevel
int