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; } } }