1 //---------------------------------------------------------------------
2 // <copyright file="AssociationSetEnd.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
10 using System
.Collections
.Generic
;
11 using System
.Data
.Common
;
15 namespace System
.Data
.Metadata
.Edm
18 /// Class representing a AssociationSet End
20 public sealed class AssociationSetEnd
: MetadataItem
24 /// Initializes a new instance of AssocationSetEnd
26 /// <param name="entitySet">Entity set that this end refers to</param>
27 /// <param name="parentSet">The association set which this belongs to</param>
28 /// <param name="endMember">The end member of the association set which this is an instance of</param>
29 /// <exception cref="System.ArgumentNullException">Thrown if either the role,entitySet, parentSet or endMember arguments are null </exception>
30 internal AssociationSetEnd(EntitySet entitySet
, AssociationSet parentSet
, AssociationEndMember endMember
)
32 _entitySet
= EntityUtil
.GenericCheckArgumentNull(entitySet
, "entitySet");
33 _parentSet
= EntityUtil
.GenericCheckArgumentNull(parentSet
, "parentSet");
34 _endMember
= EntityUtil
.GenericCheckArgumentNull(endMember
, "endMember");
39 private readonly EntitySet _entitySet
;
40 private readonly AssociationSet _parentSet
;
41 private readonly AssociationEndMember _endMember
;
46 /// Returns the kind of the type
48 public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.AssociationSetEnd; }
}
51 /// The parent association set for this AssociationSetEnd.
53 /// <exception cref="System.ArgumentNullException">Thrown if the value passed in for the setter is null </exception>
54 /// <exception cref="System.InvalidOperationException">Thrown if Setter is called when the AssociationSetEnd instance is in ReadOnly state</exception>
55 [MetadataProperty(BuiltInTypeKind
.AssociationSet
, false)]
56 public AssociationSet ParentAssociationSet
65 /// The EndMember which this AssociationSetEnd corresponds to.
67 /// <exception cref="System.ArgumentNullException">Thrown if the value passed in for the setter is null </exception>
68 /// <exception cref="System.InvalidOperationException">Thrown if Setter is called when the AssociationSetEnd instance is in ReadOnly state</exception>
69 [MetadataProperty(BuiltInTypeKind
.AssociationEndMember
, false)]
70 public AssociationEndMember CorrespondingAssociationEndMember
81 [MetadataProperty(PrimitiveTypeKind
.String
, false)]
86 return CorrespondingAssociationEndMember
.Name
;
91 /// Name of the end role
93 /// <exception cref="System.ArgumentNullException">Thrown if the value passed in for the setter is null </exception>
94 /// <exception cref="System.InvalidOperationException">Thrown if Setter is called when the AssociationSetEnd instance is in ReadOnly state</exception>
95 [MetadataProperty(PrimitiveTypeKind
.String
, false)]
96 [Obsolete("This property is going away, please use the Name property instead")]
106 /// Returns the entity set referred by this end role
108 [MetadataProperty(BuiltInTypeKind
.EntitySet
, false)]
109 public EntitySet EntitySet
118 /// Gets the identity of this item
120 internal override string Identity
131 /// Overriding System.Object.ToString to provide better String representation
134 public override string ToString()
140 /// Sets this item to be readonly, once this is set, the item will never be writable again.
142 internal override void SetReadOnly()
148 AssociationSet parentAssociationSet
= ParentAssociationSet
;
149 if (parentAssociationSet
!= null)
151 parentAssociationSet
.SetReadOnly();
154 AssociationEndMember endMember
= CorrespondingAssociationEndMember
;
155 if (endMember
!= null)
157 endMember
.SetReadOnly();
160 EntitySet entitySet
= EntitySet
;
161 if (entitySet
!= null)
163 entitySet
.SetReadOnly();