protected override void InvokeInternal(CommandProcessorContext cpc) { var cp = new CommandProcessor(cpc); CreateFunctionComplexPropertyCommand preReqCmd = null; for (var i = 0; i < _propertyChain.Count; i++) { var property = _propertyChain[i]; Debug.Assert(property.EntityModel.IsCSDL, "Each Property in the chain must be in the CSDL"); var complexConceptualProperty = property as ComplexConceptualProperty; if (complexConceptualProperty != null) { Debug.Assert(i < _propertyChain.Count - 1, "Last property shouldn't be ComplexConceptualProperty"); CreateFunctionComplexPropertyCommand cmd = null; if (preReqCmd == null) { // first property has a mapping whose parent is the ModificationFunction itself cmd = new CreateFunctionComplexPropertyCommand(_modificationFunction, complexConceptualProperty); } else { // later properties have a mapping whose parent is the ComplexProperty produced from the previous command cmd = new CreateFunctionComplexPropertyCommand(preReqCmd, complexConceptualProperty); } // set up the prereq Command to use for next time around this loop and for the // CreateFunctionScalarPropertyCommand below preReqCmd = cmd; // enqueue the command cp.EnqueueCommand(cmd); } else { Debug.Assert(i == _propertyChain.Count - 1, "This should be the last property"); CreateFunctionScalarPropertyCommand cmd = null; if (preReqCmd == null) { // create the FunctionScalarProperty command without any other properties in the property chain cmd = new CreateFunctionScalarPropertyCommand( _modificationFunction, property, _navPropPointingToProperty, _parameter, _version); } else { // create the FunctionScalarProperty command using the command for the previous property in the property chain cmd = new CreateFunctionScalarPropertyCommand(preReqCmd, property, _navPropPointingToProperty, _parameter, _version); } cp.EnqueueCommand(cmd); cp.Invoke(); _createdProperty = cmd.FunctionScalarProperty; if (_createdProperty != null) { XmlModelHelper.NormalizeAndResolve(_createdProperty); } return; } } }
/// <summary> /// Creates a FunctionComplexProperty using a FunctionComplexProperty from prereq command /// </summary> /// <param name="prereq">Pre-requisite Command which will produce the FunctionComplexProperty inside which the newly produced FunctionComplexProperty will be placed</param> /// <param name="property">This must be a valid ComplexConceptualProperty.</param> internal CreateFunctionComplexPropertyCommand(CreateFunctionComplexPropertyCommand prereq, ComplexConceptualProperty property) : base(PrereqId) { ValidatePrereqCommand(prereq); CommandValidation.ValidateConceptualProperty(property); _property = property; AddPreReqCommand(prereq); }
/// <summary> /// Creates a ScalarProperty element that maps the passed in Property to the Parameter, inside /// the ComplexProperty given by the passed in CreateFunctionComplexPropertyCommand pre-req Command. /// </summary> /// <param name="prereq"></param> /// <param name="property"></param> /// <param name="navPropPointingToProperty"></param> /// <param name="parm"></param> /// <param name="version">Optional</param> internal CreateFunctionScalarPropertyCommand( CreateFunctionComplexPropertyCommand prereq, Property property, NavigationProperty navPropPointingToProperty, Parameter parm, string version) : base(PrereqId) { ValidatePrereqCommand(prereq); CommandValidation.ValidateProperty(property); CommandValidation.ValidateParameter(parm); // we don't require a non-null navigation property since the function scalar property could exist // directly in its parent if (navPropPointingToProperty != null) { CommandValidation.ValidateNavigationProperty(navPropPointingToProperty); } _property = property; _pointingNavProperty = navPropPointingToProperty; _parm = parm; _version = version; _parentModFunc = null; // parent should be a ComplexProperty from the prereq Command AddPreReqCommand(prereq); }