/// <summary>
        ///     Creates new ScalarProperty inside specified FunctionImportTypeMapping
        /// </summary>
        /// <param name="typeMapping"></param>
        /// <param name="property">Valid c-side Property (either from EntityType or ComplexType)</param>
        /// <param name="columnName"></param>
        internal CreateFunctionImportScalarPropertyCommand(FunctionImportTypeMapping typeMapping, Property property, string columnName)
        {
            CommandValidation.ValidateFunctionImportTypeMapping(typeMapping);
            CommandValidation.ValidateConceptualProperty(property);
            ValidateString(columnName);

            _typeMapping = typeMapping;
            _property = property;
            _columnName = columnName;
        }
        protected override void ProcessPreReqCommands()
        {
            if (_typeMapping == null)
            {
                var prereq = GetPreReqCommand(CreateFunctionImportTypeMappingCommand.PrereqId) as CreateFunctionImportTypeMappingCommand;
                if (prereq != null)
                {
                    _typeMapping = prereq.TypeMapping;
                }

                Debug.Assert(_typeMapping != null, "We didn't get good FunctionImportTypeMapping out of the prereq command");
            }
        }
예제 #3
0
 internal FunctionImportScalarProperty(FunctionImportTypeMapping parent, XElement element)
     : base(parent, element)
 {
 }
예제 #4
0
 internal void AddTypeMapping(FunctionImportTypeMapping typeMapping)
 {
     _typeMappings.Add(typeMapping);
 }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // safety check, this should never be hit
            if ((_entityType == null && _complexType == null)
                || _functionImportMapping == null)
            {
                throw new InvalidOperationException(
                    "InvokeInternal is called when _entityType or _complexType or _functionImportMapping is null.");
            }

            if (_functionImportMapping.ResultMapping == null)
            {
                _functionImportMapping.ResultMapping = new ResultMapping(_functionImportMapping, null);
                XmlModelHelper.NormalizeAndResolve(_functionImportMapping.ResultMapping);
            }

            // first check if we already have one (if found we'll simply return it)
            _createdTypeMapping = _entityType != null
                                      ? _functionImportMapping.ResultMapping.FindTypeMapping(_entityType)
                                      : _functionImportMapping.ResultMapping.FindTypeMapping(_complexType);

            if (_createdTypeMapping == null)
            {
                if (_entityType != null)
                {
                    _createdTypeMapping = new FunctionImportEntityTypeMapping(_functionImportMapping.ResultMapping, null);
                    _createdTypeMapping.TypeName.SetRefName(_entityType);
                }
                else
                {
                    _createdTypeMapping = new FunctionImportComplexTypeMapping(_functionImportMapping.ResultMapping, null);
                    _createdTypeMapping.TypeName.SetRefName(_complexType);
                }

                XmlModelHelper.NormalizeAndResolve(_createdTypeMapping);
                _functionImportMapping.ResultMapping.AddTypeMapping(_createdTypeMapping);
            }

            if (_createDefaultScalarProperties && _createdTypeMapping != null)
            {
                IEnumerable<Property> properties = null;

                if (_entityType != null)
                {
                    properties = _entityType.Properties();
                }
                else if (_complexType != null)
                {
                    properties = _complexType.Properties();
                }

                if (properties != null)
                {
                    foreach (var prop in properties)
                    {
                        // Skip if the property is a Complex Property or if we already have the Scalar Property in the type mapping.
                        if ((prop is ComplexConceptualProperty) == false
                            && _createdTypeMapping.FindScalarProperty(prop) == null)
                        {
                            var columnName = (_mapPropertyNameToColumnName != null
                                              && _mapPropertyNameToColumnName.ContainsKey(prop.DisplayName)
                                                  ? _mapPropertyNameToColumnName[prop.DisplayName]
                                                  : prop.DisplayName);
                            CommandProcessor.InvokeSingleCommand(
                                cpc, new CreateFunctionImportScalarPropertyCommand(_createdTypeMapping, prop, columnName));
                        }
                    }
                }
            }
        }
예제 #6
0
 internal void AddTypeMapping(FunctionImportTypeMapping typeMapping)
 {
     _typeMappings.Add(typeMapping);
 }
예제 #7
0
 internal static void ValidateFunctionImportTypeMapping(FunctionImportTypeMapping typeMapping)
 {
     ValidateEFElement(typeMapping);
 }