コード例 #1
0
        internal ModelAssociationSet(EDMXFile parentFile, ConceptualModel conceptualModel, string name, ModelEntitySet fromES, ModelEntitySet toES, ModelEntityType fromET, ModelEntityType toET, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, string fromNavProperty, string toNavProperty, List <Tuple <ModelMemberProperty, ModelMemberProperty> > keys)
            : base(parentFile)
        {
            _conceptualModel = conceptualModel;

            bool manyToMany = (fromMultiplicity == MultiplicityTypeEnum.Many && toMultiplicity == MultiplicityTypeEnum.Many);

            _associationSetElement = CreateAssociationSet();
            _associationElement    = CreateAssociation(name, manyToMany);

            Name = name;

            //set from/to sets and multiplicity
            FromEntitySet    = fromES;
            FromEntityType   = fromET;
            FromMultiplicity = fromMultiplicity;
            ToEntitySet      = toES;
            ToEntityType     = toET;
            ToMultiplicity   = toMultiplicity;

            //add navigation properties
            if (!string.IsNullOrEmpty(fromNavProperty))
            {
                fromET.AddNavigationMember(fromNavProperty, this, FromRoleName, ToRoleName);
            }
            if (!string.IsNullOrEmpty(toNavProperty))
            {
                toET.AddNavigationMember(toNavProperty, this, ToRoleName, FromRoleName);
            }

            if (keys != null)
            {
                foreach (Tuple <ModelMemberProperty, ModelMemberProperty> key in keys)
                {
                    AddKey(key.Item1, key.Item2);
                }
            }

            _keysEnumerated = true;
        }
コード例 #2
0
        internal ModelAssociationSet(EDMXFile parentFile, ConceptualModel conceptualModel, string name, ModelEntitySet fromES, ModelEntitySet toES, ModelEntityType fromET, ModelEntityType toET, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, string fromNavProperty, string toNavProperty, List<Tuple<ModelMemberProperty, ModelMemberProperty>> keys)
            : base(parentFile)
        {
            _conceptualModel = conceptualModel;

            bool manyToMany = (fromMultiplicity == MultiplicityTypeEnum.Many && toMultiplicity == MultiplicityTypeEnum.Many);

            _associationSetElement = CreateAssociationSet();
            _associationElement = CreateAssociation(name, manyToMany);

            Name = name;

            //set from/to sets and multiplicity
            FromEntitySet = fromES;
            FromEntityType = fromET;
            FromMultiplicity = fromMultiplicity;
            ToEntitySet = toES;
            ToEntityType = toET;
            ToMultiplicity = toMultiplicity;

            //add navigation properties
            if (!string.IsNullOrEmpty(fromNavProperty))
            {
                fromET.AddNavigationMember(fromNavProperty, this, FromRoleName, ToRoleName);
            }
            if (!string.IsNullOrEmpty(toNavProperty))
            {
                toET.AddNavigationMember(toNavProperty, this, ToRoleName, FromRoleName);
            }

            if (keys != null)
            {
                foreach (Tuple<ModelMemberProperty, ModelMemberProperty> key in keys)
                {
                    AddKey(key.Item1, key.Item2);
                }
            }

            _keysEnumerated = true;
        }