Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Mapping / ViewGeneration / Structures / CaseStatementProjectedSlot.cs
1 //---------------------------------------------------------------------
2 // <copyright file="CaseStatementProjectedSlot.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner [....]
7 // @backupOwner [....]
8 //---------------------------------------------------------------------
9
10 using System.Data.Mapping.ViewGeneration.CqlGeneration;
11 using System.Text;
12 using System.Collections.Generic;
13 using System.Data.Common.CommandTrees;
14 using System.Data.Common.CommandTrees.ExpressionBuilder;
15
16 namespace System.Data.Mapping.ViewGeneration.Structures
17 {
18     /// <summary>
19     /// This class is just a wrapper over case statements so that we don't pollute the <see cref="CaseStatement"/> class itself.
20     /// </summary>
21     internal sealed class CaseStatementProjectedSlot : ProjectedSlot
22     {
23         #region Constructor
24         /// <summary>
25         /// Creates a slot for <paramref name="statement"/>.
26         /// </summary>
27         internal CaseStatementProjectedSlot(CaseStatement statement, IEnumerable<WithRelationship> withRelationships)
28         {
29             m_caseStatement = statement;
30             m_withRelationships = withRelationships;
31         }
32         #endregion
33
34         #region Fields
35         /// <summary>
36         /// The actual case statement.
37         /// </summary>
38         private readonly CaseStatement m_caseStatement;
39         private readonly IEnumerable<WithRelationship> m_withRelationships;
40         #endregion
41
42         #region Methods
43         /// <summary>
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"/>).
47         /// </summary>
48         internal override ProjectedSlot DeepQualify(CqlBlock block)
49         {
50             CaseStatement newStatement = m_caseStatement.DeepQualify(block);
51             return new CaseStatementProjectedSlot(newStatement, null);
52         }
53
54         internal override StringBuilder AsEsql(StringBuilder builder, MemberPath outputMember, string blockAlias, int indentLevel)
55         {
56             m_caseStatement.AsEsql(builder, m_withRelationships, blockAlias, indentLevel);
57             return builder;
58         }
59
60         internal override DbExpression AsCqt(DbExpression row, MemberPath outputMember)
61         {
62             return m_caseStatement.AsCqt(row, m_withRelationships);
63         }
64
65         internal override void ToCompactString(StringBuilder builder)
66         {
67             m_caseStatement.ToCompactString(builder);
68         }
69         #endregion
70     }
71 }