protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // if don't have an ECM yet, go create one
            if (_entityContainerMapping == null)
            {
                var cmd = new CreateEntityContainerMappingCommand(_entitySet.Artifact);
                CommandProcessor.InvokeSingleCommand(cpc, cmd);

                _entityContainerMapping = cmd.EntityContainerMapping;
            }

            Debug.Assert(_entityContainerMapping != null, "_entityContainerMapping should not be null");
            if (_entityContainerMapping == null)
            {
                throw new CannotLocateParentItemException();
            }

            // create the ESM
            var esm = new EntitySetMapping(_entityContainerMapping, null);

            esm.Name.SetRefName(_entitySet);
            _entityContainerMapping.AddEntitySetMapping(esm);

            XmlModelHelper.NormalizeAndResolve(esm);

            _created = esm;
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // if don't have an ECM yet, go create one
            if (_entityContainerMapping == null)
            {
                var cmd = new CreateEntityContainerMappingCommand(_entitySet.Artifact);
                CommandProcessor.InvokeSingleCommand(cpc, cmd);

                _entityContainerMapping = cmd.EntityContainerMapping;
            }

            Debug.Assert(_entityContainerMapping != null, "_entityContainerMapping should not be null");
            if (_entityContainerMapping == null)
            {
                throw new CannotLocateParentItemException();
            }

            // create the ESM
            var esm = new EntitySetMapping(_entityContainerMapping, null);
            esm.Name.SetRefName(_entitySet);
            _entityContainerMapping.AddEntitySetMapping(esm);

            XmlModelHelper.NormalizeAndResolve(esm);

            _created = esm;
        }
예제 #3
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // if we don't have an ECM yet, go create one
            if (EntityContainerMapping == null)
            {
                var createECM = new CreateEntityContainerMappingCommand(AssociationSet.Artifact);
                CommandProcessor.InvokeSingleCommand(cpc, createECM);
                EntityContainerMapping = createECM.EntityContainerMapping;
            }

            Debug.Assert(EntityContainerMapping != null, "EntityContainerMapping should not be null");
            if (EntityContainerMapping == null)
            {
                throw new CannotLocateParentItemException();
            }

            // create the ETM
            var asm = new AssociationSetMapping(EntityContainerMapping, null);

            asm.Name.SetRefName(AssociationSet);
            asm.TypeName.SetRefName(Association);
            asm.StoreEntitySet.SetRefName(StorageEntitySet);
            EntityContainerMapping.AddAssociationSetMapping(asm);

            XmlModelHelper.NormalizeAndResolve(asm);

            Debug.Assert(asm.Name.Target != null, "Could not resolve association set reference");
            Debug.Assert(asm.TypeName.Target != null, "Could not resolve association type reference");
            Debug.Assert(asm.StoreEntitySet.Target != null, "Could not resolve table reference");

            var assoc = asm.TypeName.Target;

            Debug.Assert(assoc != null, "Could not resolve association reference");
            if (assoc != null)
            {
                InferReferentialConstraints.AddRule(cpc, assoc);
            }

            _created = asm;
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // if we don't have an ECM yet, go create one
            if (EntityContainerMapping == null)
            {
                var createECM = new CreateEntityContainerMappingCommand(AssociationSet.Artifact);
                CommandProcessor.InvokeSingleCommand(cpc, createECM);
                EntityContainerMapping = createECM.EntityContainerMapping;
            }

            Debug.Assert(EntityContainerMapping != null, "EntityContainerMapping should not be null");
            if (EntityContainerMapping == null)
            {
                throw new CannotLocateParentItemException();
            }

            // create the ETM
            var asm = new AssociationSetMapping(EntityContainerMapping, null);
            asm.Name.SetRefName(AssociationSet);
            asm.TypeName.SetRefName(Association);
            asm.StoreEntitySet.SetRefName(StorageEntitySet);
            EntityContainerMapping.AddAssociationSetMapping(asm);

            XmlModelHelper.NormalizeAndResolve(asm);

            Debug.Assert(asm.Name.Target != null, "Could not resolve association set reference");
            Debug.Assert(asm.TypeName.Target != null, "Could not resolve association type reference");
            Debug.Assert(asm.StoreEntitySet.Target != null, "Could not resolve table reference");

            var assoc = asm.TypeName.Target;
            Debug.Assert(assoc != null, "Could not resolve association reference");
            if (assoc != null)
            {
                InferReferentialConstraints.AddRule(cpc, assoc);
            }

            _created = asm;
        }