1 //---------------------------------------------------------------------
2 // <copyright file="RoleBoolean.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
10 namespace System.Data.Mapping.ViewGeneration.Structures
12 using System.Collections.Generic;
13 using System.Data.Common.CommandTrees;
14 using System.Data.Entity;
15 using System.Data.Metadata.Edm;
16 using System.Diagnostics;
20 /// Denotes the fact that the key of the current tuple comes from a specific extent, or association role.
22 internal sealed class RoleBoolean : TrueFalseLiteral
25 internal RoleBoolean(EntitySetBase extent)
27 m_metadataItem = extent;
29 internal RoleBoolean(AssociationSetEnd end)
36 private readonly MetadataItem m_metadataItem;
39 #region BoolLiteral members
41 /// Not supported in this class.
43 internal override StringBuilder AsEsql(StringBuilder builder, string blockAlias, bool skipIsNotNull)
45 Debug.Fail("Should not be called.");
46 return null; // To keep the compiler happy
50 /// Not supported in this class.
52 internal override DbExpression AsCqt(DbExpression row, bool skipIsNotNull)
54 Debug.Fail("Should not be called.");
55 return null; // To keep the compiler happy
58 internal override StringBuilder AsUserString(StringBuilder builder, string blockAlias, bool skipIsNotNull)
60 AssociationSetEnd end = m_metadataItem as AssociationSetEnd;
63 builder.Append(Strings.ViewGen_AssociationSet_AsUserString(blockAlias, end.Name, end.ParentAssociationSet));
67 builder.Append(Strings.ViewGen_EntitySet_AsUserString(blockAlias, m_metadataItem.ToString()));
72 internal override StringBuilder AsNegatedUserString(StringBuilder builder, string blockAlias, bool skipIsNotNull)
74 AssociationSetEnd end = m_metadataItem as AssociationSetEnd;
77 builder.Append(Strings.ViewGen_AssociationSet_AsUserString_Negated(blockAlias, end.Name, end.ParentAssociationSet));
81 builder.Append(Strings.ViewGen_EntitySet_AsUserString_Negated(blockAlias, m_metadataItem.ToString()));
86 internal override void GetRequiredSlots(MemberProjectionIndex projectedSlotMap, bool[] requiredSlots)
88 throw new NotImplementedException();
91 protected override bool IsEqualTo(BoolLiteral right)
93 RoleBoolean rightBoolean = right as RoleBoolean;
94 if (rightBoolean == null)
98 return m_metadataItem == rightBoolean.m_metadataItem;
101 public override int GetHashCode()
103 return m_metadataItem.GetHashCode();
106 internal override BoolLiteral RemapBool(Dictionary<MemberPath, MemberPath> remap)
112 #region Other Methods
113 internal override void ToCompactString(StringBuilder builder)
115 AssociationSetEnd end = m_metadataItem as AssociationSetEnd;
118 builder.Append("InEnd:" + end.ParentAssociationSet + "_" + end.Name);
122 builder.Append("InSet:" + m_metadataItem.ToString());