//---------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Data.Metadata.Edm;
namespace System.Data.Mapping {
///
/// Mapping metadata for Complex properties.
///
///
/// 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 complex property map elements in the
/// above example. ComplexPropertyMaps contain ComplexTypeMaps which define mapping based
/// on the type of the ComplexProperty in case of inheritance.
///
internal class StorageComplexPropertyMapping : StoragePropertyMapping {
#region Constructors
///
/// Construct a new Complex Property mapping object
///
/// The MemberMetadata object that represents this Complex member
internal StorageComplexPropertyMapping(EdmProperty cdmMember)
: base(cdmMember) {
this.m_typeMappings = new List();
}
#endregion
#region Fields
///
/// Set of type mappings that make up the EdmProperty mapping.
///
private List m_typeMappings;
#endregion
#region Properties
/////
///// The property Metadata object for which the mapping is represented.
/////
//internal EdmProperty ComplexProperty {
// get {
// return this.EdmProperty;
// }
//}
///
/// TypeMappings that make up this property.
///
internal ReadOnlyCollection TypeMappings
{
get
{
return this.m_typeMappings.AsReadOnly();
}
}
#endregion
#region Methods
///
/// Add type mapping as a child under this Property Mapping
///
///
internal void AddTypeMapping(StorageComplexTypeMapping typeMapping)
{
this.m_typeMappings.Add(typeMapping);
}
///
/// 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("ComplexPropertyMapping");
sb.Append(" ");
if (this.EdmProperty != null) {
sb.Append("Name:");
sb.Append(this.EdmProperty.Name);
sb.Append(" ");
}
Console.WriteLine(sb.ToString());
foreach (StorageComplexTypeMapping typeMapping in TypeMappings)
{
typeMapping.Print(index + 5);
}
}
#endregion
}
}