Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Mapping / StorageAssociationSetMapping.cs
1 //---------------------------------------------------------------------
2 // <copyright file="StorageAssociationSetMapping.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner       Microsoft
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
9
10 using System;
11 using System.Collections.Generic;
12 using System.Text;
13 using System.Linq;
14 using System.Data.Metadata.Edm;
15
16 namespace System.Data.Mapping {
17     /// <summary>
18     /// Represents the Mapping metadata for an AssociationSet in CS space.
19     /// </summary>
20     /// <example>
21     /// For Example if conceptually you could represent the CS MSL file as following
22     /// --Mapping 
23     ///   --EntityContainerMapping ( CNorthwind-->SNorthwind )
24     ///     --EntitySetMapping
25     ///       --EntityTypeMapping
26     ///         --MappingFragment
27     ///       --EntityTypeMapping
28     ///         --MappingFragment
29     ///     --AssociationSetMapping 
30     ///       --AssociationTypeMapping
31     ///         --MappingFragment
32     /// This class represents the metadata for the AssociationSetMapping elements in the
33     /// above example. And it is possible to access the AssociationTypeMap underneath it.
34     /// There will be only one TypeMap under AssociationSetMap.
35     /// </example>
36     internal class StorageAssociationSetMapping : StorageSetMapping {
37         #region Constructors
38         /// <summary>
39         /// Construct a new AssociationSetMapping object
40         /// </summary>
41         /// <param name="extent">Represents the Association Set Metadata object. Will
42         ///                      change this to Extent instead of MemberMetadata.</param>
43         /// <param name="entityContainerMapping">The entityContainerMapping mapping that contains this Set mapping</param>
44         internal StorageAssociationSetMapping(AssociationSet extent, StorageEntityContainerMapping entityContainerMapping)
45             : base(extent, entityContainerMapping) {
46         }
47         #endregion
48
49         #region Fields
50         private StorageAssociationSetModificationFunctionMapping m_modificationFunctionMapping;
51         #endregion
52
53         #region Properties
54         /// <summary>
55         /// Gets or sets function mapping information for this association set. May be null.
56         /// </summary>
57         internal StorageAssociationSetModificationFunctionMapping ModificationFunctionMapping {
58             get { return m_modificationFunctionMapping; }
59             set { m_modificationFunctionMapping = value; }
60         }
61
62         internal EntitySetBase StoreEntitySet
63         {
64             get
65             {
66                 if ((this.TypeMappings.Count != 0) && (this.TypeMappings.First().MappingFragments.Count != 0))
67                 {
68                     return this.TypeMappings.First().MappingFragments.First().TableSet;
69                 }
70                 return null;
71             }
72         }
73         #endregion
74
75         #region Methods
76         /// <summary>
77         /// This method is primarily for debugging purposes.
78         /// Will be removed shortly.
79         /// </summary>
80         /// <param name="index"></param>
81         internal override void Print(int index) {
82             StorageEntityContainerMapping.GetPrettyPrintString(ref index);
83             StringBuilder sb = new StringBuilder();
84             sb.Append("AssociationSetMapping");
85             sb.Append("   ");
86             sb.Append("Name:");
87             sb.Append(this.Set.Name);
88             if (this.QueryView != null)
89             {
90                 sb.Append("   ");
91                 sb.Append("Query View:");
92                 sb.Append(this.QueryView);
93             }
94             Console.WriteLine(sb.ToString());
95             foreach (StorageTypeMapping typeMapping in TypeMappings) {
96                 typeMapping.Print(index + 5);
97             }
98             if(m_modificationFunctionMapping != null)
99             {
100                 m_modificationFunctionMapping.Print(index + 5);
101             }
102         }
103         #endregion
104     }
105 }