1 //---------------------------------------------------------------------
2 // <copyright file="CaseStatementProjectedSlot.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
8 //---------------------------------------------------------------------
10 using System.Data.Mapping.ViewGeneration.CqlGeneration;
12 using System.Collections.Generic;
13 using System.Data.Common.CommandTrees;
14 using System.Data.Common.CommandTrees.ExpressionBuilder;
16 namespace System.Data.Mapping.ViewGeneration.Structures
19 /// This class is just a wrapper over case statements so that we don't pollute the <see cref="CaseStatement"/> class itself.
21 internal sealed class CaseStatementProjectedSlot : ProjectedSlot
25 /// Creates a slot for <paramref name="statement"/>.
27 internal CaseStatementProjectedSlot(CaseStatement statement, IEnumerable<WithRelationship> withRelationships)
29 m_caseStatement = statement;
30 m_withRelationships = withRelationships;
36 /// The actual case statement.
38 private readonly CaseStatement m_caseStatement;
39 private readonly IEnumerable<WithRelationship> m_withRelationships;
44 /// Creates new <see cref="ProjectedSlot"/> that is qualified with <paramref name="block"/>.CqlAlias.
45 /// If current slot is composite (such as <see cref="CaseStatementProjectedSlot"/>, then this method recursively qualifies all parts
46 /// and returns a new deeply qualified slot (as opposed to <see cref="CqlBlock.QualifySlotWithBlockAlias"/>).
48 internal override ProjectedSlot DeepQualify(CqlBlock block)
50 CaseStatement newStatement = m_caseStatement.DeepQualify(block);
51 return new CaseStatementProjectedSlot(newStatement, null);
54 internal override StringBuilder AsEsql(StringBuilder builder, MemberPath outputMember, string blockAlias, int indentLevel)
56 m_caseStatement.AsEsql(builder, m_withRelationships, blockAlias, indentLevel);
60 internal override DbExpression AsCqt(DbExpression row, MemberPath outputMember)
62 return m_caseStatement.AsCqt(row, m_withRelationships);
65 internal override void ToCompactString(StringBuilder builder)
67 m_caseStatement.ToCompactString(builder);