//--------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Data.Metadata.Edm; namespace System.Data.Mapping { /// /// Mapping metadata for End property of an association. /// /// /// For Example if conceptually you could represent the CS MSL file as following /// --Mapping /// --EntityContainerMapping ( CNorthwind-->SNorthwind ) /// --EntitySetMapping /// --EntityTypeMapping /// --MappingFragment /// --EntityKey /// --ScalarPropertyMap ( CMemberMetadata-->SMemberMetadata ) /// --ScalarPropertyMap ( CMemberMetadata-->SMemberMetadata ) /// --EntityTypeMapping /// --MappingFragment /// --EntityKey /// --ScalarPropertyMap ( CMemberMetadata-->SMemberMetadata ) /// --ComplexPropertyMap /// --ComplexTypeMapping /// --ScalarPropertyMap ( CMemberMetadata-->SMemberMetadata ) /// --ScalarProperyMap ( CMemberMetadata-->SMemberMetadata ) /// --DiscriminatorProperyMap ( constant value-->SMemberMetadata ) /// --ComplexTypeMapping /// --ScalarPropertyMap ( CMemberMetadata-->SMemberMetadata ) /// --ScalarProperyMap ( CMemberMetadata-->SMemberMetadata ) /// --DiscriminatorProperyMap ( constant value-->SMemberMetadata ) /// --ScalarPropertyMap ( CMemberMetadata-->SMemberMetadata ) /// --AssociationSetMapping /// --AssociationTypeMapping /// --MappingFragment /// --EndPropertyMap /// --ScalarPropertyMap ( CMemberMetadata-->SMemberMetadata ) /// --ScalarProperyMap ( CMemberMetadata-->SMemberMetadata ) /// --EndPropertyMap /// --ScalarPropertyMap ( CMemberMetadata-->SMemberMetadata ) /// This class represents the metadata for all the end property map elements in the /// above example. EndPropertyMaps provide mapping for each end of the association. /// internal class StorageEndPropertyMapping : StoragePropertyMapping { #region Constructors /// /// Construct a new End Property mapping object /// /// internal StorageEndPropertyMapping(EdmProperty member) : base(member) { } #endregion #region Fields /// /// List of property mappings that make up the End. /// List m_properties = new List(); RelationshipEndMember m_endMember = null; #endregion #region Properties /// /// return ReadOnlyCollection of property mappings that are children of this End mapping /// internal ReadOnlyCollection Properties { get { return this.m_properties.AsReadOnly(); } } /// /// The relation end property Metadata object for which the mapping is represented. /// internal RelationshipEndMember EndMember { get { return this.m_endMember; } set { this.m_endMember = value; } } /// /// Returns all store properties that are mapped under this mapping fragment /// internal IEnumerable StoreProperties { get { return m_properties.OfType().Select((propertyMap => propertyMap.ColumnProperty)).Cast(); } } #endregion #region Methods /// /// Add a property mapping as a child of End property mapping /// /// internal void AddProperty(StoragePropertyMapping prop) { this.m_properties.Add(prop); } /// /// This method is primarily for debugging purposes. /// Will be removed shortly. /// /// internal override void Print(int index) { StorageEntityContainerMapping.GetPrettyPrintString(ref index); StringBuilder sb = new StringBuilder(); sb.Append("EndPropertyMapping"); sb.Append(" "); if (this.EndMember != null) { sb.Append("Name:"); sb.Append(this.EndMember.Name); sb.Append(" "); sb.Append("TypeName:"); sb.Append(this.EndMember.TypeUsage.EdmType.FullName); } sb.Append(" "); Console.WriteLine(sb.ToString()); foreach (StoragePropertyMapping propertyMapping in Properties) { propertyMapping.Print(index + 5); } } #endregion } }