public void Can_get_association_set_mapping() { var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); var associationSetMapping = new AssociationSetMapping( new AssociationSet("AS", associationType), new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace))); var associationTypeMapping = new AssociationTypeMapping(associationSetMapping); Assert.Same(associationSetMapping, associationTypeMapping.AssociationSetMapping); }
/// <summary> /// Initializes a new AssociationSetMapping instance. /// </summary> /// <param name="associationSet">The association set to be mapped.</param> /// <param name="storeEntitySet">The store entity set to be mapped.</param> /// <param name="containerMapping">The parent container mapping.</param> public AssociationSetMapping(AssociationSet associationSet, EntitySet storeEntitySet, EntityContainerMapping containerMapping) : base(containerMapping) { Check.NotNull(associationSet, "associationSet"); Check.NotNull(storeEntitySet, "storeEntitySet"); _associationSet = associationSet; _associationTypeMapping = new AssociationTypeMapping(associationSet.ElementType, this); _associationTypeMapping.MappingFragment = new MappingFragment(storeEntitySet, _associationTypeMapping, false); }
public void SetReadOnly_is_called_on_child_mapping_items() { var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); var associationSet = new AssociationSet("AS", associationType); var associationSetMapping = new AssociationSetMapping( associationSet, new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace))); var associationTypeMapping = new AssociationTypeMapping(associationSetMapping); var fragment = new MappingFragment(new EntitySet(), associationTypeMapping, false); associationTypeMapping.MappingFragment = fragment; Assert.False(fragment.IsReadOnly); associationTypeMapping.SetReadOnly(); Assert.True(fragment.IsReadOnly); }
// <summary> // Finds members participating in the assocciation and adds them to the <paramref name="interestingMembers" />. // </summary> // <param name="associationTypeMapping"> Association type mapping. Must not be null. </param> // <param name="interestingMembers"> The list the interesting members (if any) will be added to. Must not be null. </param> private static void FindInterestingAssociationMappingMembers( AssociationTypeMapping associationTypeMapping, List<EdmMember> interestingMembers) { DebugCheck.NotNull(associationTypeMapping); DebugCheck.NotNull(interestingMembers); //(2) Ends participating in association are "interesting" interestingMembers.AddRange( associationTypeMapping .MappingFragments .SelectMany(m => m.AllProperties) .OfType<EndPropertyMapping>() .Select(epm => epm.AssociationEnd)); }
public void MappingFragments_returns_mapping_fragment_if_set() { var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); var setMapping = new AssociationSetMapping( new AssociationSet("AS", associationType), new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace))); var associationTypeMapping = new AssociationTypeMapping(setMapping); var fragment = new MappingFragment(new EntitySet(), associationTypeMapping, false); associationTypeMapping.MappingFragment = fragment; Assert.Equal(new[] { fragment }, associationTypeMapping.MappingFragments); Assert.Same(fragment, associationTypeMapping.MappingFragment); }
public static void GetIdentity_of_StorageAssociationTypeMapping_returns_expected_value() { var associationType = new AssociationType("AT", "N", false, DataSpace.CSpace); TypeMapping mapping = new AssociationTypeMapping(associationType, null); Assert.Equal(associationType.Identity, BaseMetadataMappingVisitor.IdentityHelper.GetIdentity(mapping)); }