コード例 #1
0
        internal UpdatedModelSummary(EFArtifact artifact)
        {
            _artifact = artifact;

            Debug.Assert(artifact != null, "Null artifact");

            if (artifact != null)
            {
                if (null != artifact.MappingModel() &&
                    null != artifact.MappingModel().FirstEntityContainerMapping)
                {
                    RecordEntityTypeIdentities(
                        artifact.MappingModel().FirstEntityContainerMapping);

                    // build the association summary
                    _associationSummary = AssociationSummary.ConstructAssociationSummary(artifact);
                }

                if (null != artifact.StorageModel() &&
                    null != artifact.StorageModel().FirstEntityContainer)
                {
                    var sec = artifact.StorageModel().FirstEntityContainer as StorageEntityContainer;
                    if (sec != null)
                    {
                        RecordStorageProperties(sec);
                    }
                }
            }
        }
コード例 #2
0
        internal UpdatedModelSummary(EFArtifact artifact)
        {
            _artifact = artifact;

            Debug.Assert(artifact != null, "Null artifact");

            if (artifact != null)
            {
                if (null != artifact.MappingModel()
                    && null != artifact.MappingModel().FirstEntityContainerMapping)
                {
                    RecordEntityTypeIdentities(
                        artifact.MappingModel().FirstEntityContainerMapping);

                    // build the association summary
                    _associationSummary = AssociationSummary.ConstructAssociationSummary(artifact);
                }

                if (null != artifact.StorageModel()
                    && null != artifact.StorageModel().FirstEntityContainer)
                {
                    var sec = artifact.StorageModel().FirstEntityContainer as StorageEntityContainer;
                    if (sec != null)
                    {
                        RecordStorageProperties(sec);
                    }
                }
            }
        }
コード例 #3
0
ファイル: AssociationSummary.cs プロジェクト: dotnet/ef6tools
        internal static AssociationSummary ConstructAssociationSummary(EFArtifact artifact)
        {
            var ecm = artifact.MappingModel().FirstEntityContainerMapping;

            var summary = new AssociationSummary();

            if (!EdmFeatureManager.GetForeignKeysInModelFeatureState(artifact.SchemaVersion).IsEnabled())
            {
                if (ecm != null)
                {
                    // Foreign keys in the model are not supported for this EDMX version.
                    foreach (var asm in ecm.AssociationSetMappings())
                    {
                        var cSideAssociation = asm.TypeName.Target;

                        if (null != cSideAssociation)
                        {
                            var assocId = AssociationIdentityForAssociationSetMapping.CreateAssociationIdentity(asm);
                            if (null != assocId)
                            {
                                summary.Add(cSideAssociation, assocId);
                            }
                        }
                    }
                }
            }
            else
            {
                // Foreign keys in the model are supported for this EDMX version.
                foreach (var a in artifact.ConceptualModel().Associations())
                {
                    AssociationIdentity assocId = null;
                    if (a.IsManyToMany == false &&
                        a.ReferentialConstraint != null)
                    {
                        assocId = AssociationIdentityForReferentialConstraint.CreateAssociationIdentity(a.ReferentialConstraint);
                    }
                    else
                    {
                        var asm = ModelHelper.FindAssociationSetMappingForConceptualAssociation(a);
                        if (asm != null)
                        {
                            assocId = AssociationIdentityForAssociationSetMapping.CreateAssociationIdentity(asm);
                        }
                    }
                    if (null != assocId)
                    {
                        summary.Add(a, assocId);
                    }
                }
            }
            return(summary);
        }
コード例 #4
0
        internal ExistingModelSummary(EFArtifact artifact)
        {
            _artifact = artifact;
            if (null == artifact)
            {
                Debug.Fail("Null artifact");
            }
            else
            {
                if (null != artifact.MappingModel()
                    && null != artifact.MappingModel().FirstEntityContainerMapping)
                {
                    RecordEntityTypeIdentities(
                        artifact.MappingModel().FirstEntityContainerMapping);

                    // build the association summary.
                    _associationSummary = AssociationSummary.ConstructAssociationSummary(artifact);
                }

                if (null != artifact.ConceptualModel())
                {
                    RecordInheritanceAndEntityTypeMappings(artifact.ConceptualModel());
                }

                if (null != artifact.StorageModel())
                {
                    RecordFunctions(artifact.StorageModel());

                    if (null != artifact.StorageModel().FirstEntityContainer)
                    {
                        var sec = artifact.StorageModel().FirstEntityContainer as StorageEntityContainer;
                        if (sec != null)
                        {
                            RecordStorageEntitySetsAndProperties(sec);
                        }
                    }
                }
            }
        }
コード例 #5
0
        internal ExistingModelSummary(EFArtifact artifact)
        {
            _artifact = artifact;
            if (null == artifact)
            {
                Debug.Fail("Null artifact");
            }
            else
            {
                if (null != artifact.MappingModel() &&
                    null != artifact.MappingModel().FirstEntityContainerMapping)
                {
                    RecordEntityTypeIdentities(
                        artifact.MappingModel().FirstEntityContainerMapping);

                    // build the association summary.
                    _associationSummary = AssociationSummary.ConstructAssociationSummary(artifact);
                }

                if (null != artifact.ConceptualModel())
                {
                    RecordInheritanceAndEntityTypeMappings(artifact.ConceptualModel());
                }

                if (null != artifact.StorageModel())
                {
                    RecordFunctions(artifact.StorageModel());

                    if (null != artifact.StorageModel().FirstEntityContainer)
                    {
                        var sec = artifact.StorageModel().FirstEntityContainer as StorageEntityContainer;
                        if (sec != null)
                        {
                            RecordStorageEntitySetsAndProperties(sec);
                        }
                    }
                }
            }
        }
コード例 #6
0
        internal static AssociationSummary ConstructAssociationSummary(EFArtifact artifact)
        {
            var ecm = artifact.MappingModel().FirstEntityContainerMapping;

            var summary = new AssociationSummary();

            if (!EdmFeatureManager.GetForeignKeysInModelFeatureState(artifact.SchemaVersion).IsEnabled())
            {
                if (ecm != null)
                {
                    // Foreign keys in the model are not supported for this EDMX version.
                    foreach (var asm in ecm.AssociationSetMappings())
                    {
                        var cSideAssociation = asm.TypeName.Target;

                        if (null != cSideAssociation)
                        {
                            var assocId = AssociationIdentityForAssociationSetMapping.CreateAssociationIdentity(asm);
                            if (null != assocId)
                            {
                                summary.Add(cSideAssociation, assocId);
                            }
                        }
                    }
                }
            }
            else
            {
                // Foreign keys in the model are supported for this EDMX version.
                foreach (var a in artifact.ConceptualModel().Associations())
                {
                    AssociationIdentity assocId = null;
                    if (a.IsManyToMany == false
                        && a.ReferentialConstraint != null)
                    {
                        assocId = AssociationIdentityForReferentialConstraint.CreateAssociationIdentity(a.ReferentialConstraint);
                    }
                    else
                    {
                        var asm = ModelHelper.FindAssociationSetMappingForConceptualAssociation(a);
                        if (asm != null)
                        {
                            assocId = AssociationIdentityForAssociationSetMapping.CreateAssociationIdentity(asm);
                        }
                    }
                    if (null != assocId)
                    {
                        summary.Add(a, assocId);
                    }
                }
            }
            return summary;
        }