Ejemplo n.º 1
0
        internal void LoadResultBindings()
        {
            if (null == _resultBindings)
            {
                _resultBindings = new List <MappingResultBinding>();

                if (Function != null &&
                    MappingFunctionEntityType != null &&
                    MappingFunctionEntityType.EntityType != null)
                {
                    var entityType = MappingFunctionEntityType.EntityType as ConceptualEntityType;
                    Debug.Assert(
                        MappingFunctionEntityType.EntityType == null || entityType != null, "EntityType is not ConceptualEntityType");

                    foreach (var prop in entityType.SafeInheritedAndDeclaredProperties)
                    {
                        foreach (var binding in prop.GetAntiDependenciesOfType <ResultBinding>())
                        {
                            // if we find one, validate it
                            if (binding != null &&
                                binding.Name.Status == BindingStatus.Known &&
                                binding.Name.Target != null)
                            {
                                // make sure we are looking at something mapped by the entity type we are mapping, for the same function, in the same MF
                                if (entityType
                                    != binding.ModificationFunction.ModificationFunctionMapping.EntityTypeMapping
                                    .FirstBoundConceptualEntityType ||
                                    MappingModificationFunctionMapping.Function != binding.ModificationFunction.FunctionName.Target ||
                                    ModificationFunction != binding.ModificationFunction)
                                {
                                    continue;
                                }

                                // if not, see if its already mapped by this type or its base types
                                var bindingEntityType = binding.Name.Target.Parent as EntityType;
                                var cet = bindingEntityType as ConceptualEntityType;
                                Debug.Assert(bindingEntityType != null ? cet != null : true, "EntityType is not ConceptualEntityType");

                                Debug.Assert(cet != null, "Parent of Property should be EntityType");
                                if (cet != null
                                    &&
                                    cet.GetSafeSelfAndBaseTypesAsHashSet().Contains(cet))
                                {
                                    // we are already mapping this
                                    var mrb = (MappingResultBinding)ModelToMappingModelXRef.GetNewOrExisting(_context, binding, this);
                                    _resultBindings.Add(mrb);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected override void LoadChildrenCollection()
        {
            if (EntityType != null)
            {
                // loop through every EntityTypeMapping that has a dep on this c-side entity,
                // looking to see if there in a function mapping node
                foreach (var etm in EntityType.GetAntiDependenciesOfType <EntityTypeMapping>())
                {
                    if (etm.Kind == EntityTypeMappingKind.Function)
                    {
                        if (etm.ModificationFunctionMapping.InsertFunction != null &&
                            etm.ModificationFunctionMapping.InsertFunction.FunctionName.Status == BindingStatus.Known)
                        {
                            _insertMapping =
                                (MappingModificationFunctionMapping)
                                ModelToMappingModelXRef.GetNewOrExisting(_context, etm.ModificationFunctionMapping.InsertFunction, this);
                            _insertMapping.ModificationFunctionType = ModificationFunctionType.Insert;
                        }

                        if (etm.ModificationFunctionMapping.UpdateFunction != null &&
                            etm.ModificationFunctionMapping.UpdateFunction.FunctionName.Status == BindingStatus.Known)
                        {
                            _updateMapping =
                                (MappingModificationFunctionMapping)
                                ModelToMappingModelXRef.GetNewOrExisting(_context, etm.ModificationFunctionMapping.UpdateFunction, this);
                            _updateMapping.ModificationFunctionType = ModificationFunctionType.Update;
                        }

                        if (etm.ModificationFunctionMapping.DeleteFunction != null &&
                            etm.ModificationFunctionMapping.DeleteFunction.FunctionName.Status == BindingStatus.Known)
                        {
                            _deleteMapping =
                                (MappingModificationFunctionMapping)
                                ModelToMappingModelXRef.GetNewOrExisting(_context, etm.ModificationFunctionMapping.DeleteFunction, this);
                            _deleteMapping.ModificationFunctionType = ModificationFunctionType.Delete;
                        }

                        break;
                    }
                }
            }

            _children.Add(_insertMapping);
            _children.Add(_updateMapping);
            _children.Add(_deleteMapping);
        }
Ejemplo n.º 3
0
            protected override void BuildExisting(CommandProcessorContext cpc, ScalarProperty scalarProperty)
            {
                var mesp = (MappingEndScalarProperty)ModelToMappingModelXRef.GetNewOrExisting(cpc.EditingContext, scalarProperty, _mase);

                _mase._scalarProperties.Add(mesp);
            }
Ejemplo n.º 4
0
 protected override void LoadChildrenCollection()
 {
     _assocSet = ModelToMappingModelXRef.GetNewOrExisting(_context, Association.AssociationSet, this) as MappingAssociationSet;
     _children.Add(_assocSet);
 }
        internal void LoadScalarProperties()
        {
            if (null == _scalarProperties)
            {
                _scalarProperties = new List <MappingFunctionScalarProperty>();

                // load children from model
                // note: have to go to parent to get this as this is a dummy node
                if (Function != null &&
                    MappingFunctionEntityType != null &&
                    MappingFunctionEntityType.EntityType != null)
                {
                    var entityType = MappingFunctionEntityType.EntityType;

                    // loop through all of the 'parameters' in the function
                    foreach (var parm in Function.Parameters())
                    {
                        FunctionScalarProperty existingScalarProperty = null;

                        // for each column, see if we are already have a scalar property
                        var antiDeps = parm.GetAntiDependenciesOfType <FunctionScalarProperty>();
                        foreach (var scalarProperty in antiDeps)
                        {
                            // this FunctionScalarProperty could be right under the function, nested inside an AssociationEnd,
                            // or N levels deep inside a complex type hierarchy
                            var spmf = scalarProperty.GetParentOfType(typeof(ModificationFunction)) as ModificationFunction;

                            // if we find one, validate it
                            if (scalarProperty != null &&
                                scalarProperty.Name.Status == BindingStatus.Known &&
                                spmf != null &&
                                ModificationFunction == spmf)
                            {
                                // make sure we are looking at something mapped by the entity type we are mapping
                                if (entityType != spmf.ModificationFunctionMapping.EntityTypeMapping.FirstBoundConceptualEntityType)
                                {
                                    continue;
                                }

                                // we are already mapping this
                                existingScalarProperty = scalarProperty;
                                break;
                            }
                        }

                        // if we didn't find one, then create a dummy row with just the column info
                        if (existingScalarProperty == null)
                        {
                            var msp = new MappingFunctionScalarProperty(_context, null, this);
                            msp.StoreParameter = parm;
                            _scalarProperties.Add(msp);
                        }
                        else
                        {
                            var msp =
                                (MappingFunctionScalarProperty)
                                ModelToMappingModelXRef.GetNewOrExisting(_context, existingScalarProperty, this);
                            _scalarProperties.Add(msp);
                        }
                    }
                }
            }
        }