1 //---------------------------------------------------------------------
2 // <copyright file="StorageAssociationTypeMapping.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
6 // @owner Microsoft, Microsoft
7 //---------------------------------------------------------------------
10 using System.Collections.Generic;
11 using System.Collections.ObjectModel;
13 using System.Data.Metadata.Edm;
15 namespace System.Data.Mapping {
17 /// Represents the Mapping metadata for an association type map in CS space.
20 /// For Example if conceptually you could represent the CS MSL file as following
22 /// --EntityContainerMapping ( CNorthwind-->SNorthwind )
23 /// --EntitySetMapping
24 /// --EntityTypeMapping
27 /// --ScalarPropertyMap
28 /// --ScalarPropertyMap
29 /// --EntityTypeMapping
32 /// --ScalarPropertyMap
33 /// --ComplexPropertyMap
35 /// --ScalarPropertyMap
36 /// --ScalarProperyMap
37 /// --ScalarPropertyMap
38 /// --AssociationSetMapping
39 /// --AssociationTypeMapping
42 /// --ScalarPropertyMap
43 /// --ScalarProperyMap
45 /// --ScalarPropertyMap
46 /// This class represents the metadata for all association Type map elements in the
47 /// above example. Users can access the table mapping fragments under the
48 /// association type mapping through this class.
50 internal class StorageAssociationTypeMapping : StorageTypeMapping {
53 /// Construct the new AssociationTypeMapping object.
55 /// <param name="relation">Represents the Association Type metadata object</param>
56 /// <param name="setMapping">Set Mapping that contains this Type mapping </param>
57 internal StorageAssociationTypeMapping(AssociationType relation, StorageSetMapping setMapping)
59 this.m_relation = relation;
65 /// Type for which the mapping is represented.
67 AssociationType m_relation;
72 /// The AssociationTypeType Metadata object for which the mapping is represented.
74 internal AssociationType AssociationType
77 return this.m_relation;
82 /// a list of TypeMetadata that this mapping holds true for.
83 /// Since Association types dont participate in Inheritance, This can only
86 internal override ReadOnlyCollection<EdmType> Types {
88 return new ReadOnlyCollection<EdmType>(new AssociationType[] { m_relation });
93 /// a list of TypeMetadatas for which the mapping holds true for
94 /// not only the type specified but the sub-types of that type as well.
95 /// Since Association types dont participate in Inheritance, an Empty list
98 internal override ReadOnlyCollection<EdmType> IsOfTypes {
100 return new List<EdmType>().AsReadOnly();
107 /// This method is primarily for debugging purposes.
108 /// Will be removed shortly.
110 /// <param name="index"></param>
111 internal override void Print(int index) {
112 StorageEntityContainerMapping.GetPrettyPrintString(ref index);
113 StringBuilder sb = new StringBuilder();
114 sb.Append("AssociationTypeMapping");
116 sb.Append("Type Name:");
117 sb.Append(this.m_relation.Name);
119 Console.WriteLine(sb.ToString());
120 foreach (StorageMappingFragment fragment in MappingFragments) {
121 fragment.Print(index + 5);