public override Node Visit(RefOp op, Node n) { var inputTypeInfo = m_typeInfo.GetTypeInfo((n.Child0.Op).Type); var outputTypeInfo = m_typeInfo.GetTypeInfo(op.Type); // visit children now VisitChildren(n); // Get the list of fields and properties from the input (key) op List<md.EdmProperty> inputFields; List<Node> inputFieldValues; GetPropertyValues(inputTypeInfo, OperationKind.All, n.Child0, false, out inputFields, out inputFieldValues); // Get my property list var outputFields = new List<md.EdmProperty>(outputTypeInfo.FlattenedType.Properties); if (outputTypeInfo.HasEntitySetIdProperty) { PlanCompiler.Assert(outputFields[0] == outputTypeInfo.EntitySetIdProperty, "OutputField0 must be the entitySetId property"); if (inputTypeInfo.HasNullSentinelProperty && !outputTypeInfo.HasNullSentinelProperty) { // realistically, REFs can't have null sentinels, but I'm being pedantic... PlanCompiler.Assert( outputFields.Count == inputFields.Count, "Mismatched field count: Expected " + inputFields.Count + "; Got " + outputFields.Count); RemoveNullSentinel(inputTypeInfo, inputFields, inputFieldValues); } else { PlanCompiler.Assert( outputFields.Count == inputFields.Count + 1, "Mismatched field count: Expected " + (inputFields.Count + 1) + "; Got " + outputFields.Count); } // Now prepend a value for the entitysetid property and a value for this property var entitySetId = m_typeInfo.GetEntitySetId(op.EntitySet); inputFieldValues.Insert( 0, m_command.CreateNode( m_command.CreateInternalConstantOp(md.Helper.GetModelTypeUsage(outputTypeInfo.EntitySetIdProperty), entitySetId))); } else { if (inputTypeInfo.HasNullSentinelProperty && !outputTypeInfo.HasNullSentinelProperty) { // realistically, REFs can't have null sentinels, but I'm being pedantic... RemoveNullSentinel(inputTypeInfo, inputFields, inputFieldValues); } PlanCompiler.Assert( outputFields.Count == inputFields.Count, "Mismatched field count: Expected " + inputFields.Count + "; Got " + outputFields.Count); } // now build up a NewRecordConstructor with the appropriate info var recOp = m_command.CreateNewRecordOp(outputTypeInfo.FlattenedTypeUsage, outputFields); var newNode = m_command.CreateNode(recOp, inputFieldValues); return newNode; }
/// <summary> /// Handler for a RefOp. /// Keeps track of the entityset /// </summary> /// <param name="op">the RefOp</param> /// <param name="n">current RefOp subtree</param> /// <returns>current subtree</returns> public override Node Visit(RefOp op, Node n) { VisitScalarOpDefault(op, n); // use default processing AddEntitySetReference(op.EntitySet); // add to list of references return n; }
/// <summary> /// Visitor pattern method for RefOp /// </summary> /// <param name="op"> The RefOp being visited </param> /// <param name="n"> The Node that references the Op </param> public virtual void Visit(RefOp op, Node n) { VisitScalarOpDefault(op, n); }
/// <summary> /// Copies a RefOp /// </summary> /// <param name="op">The Op to Copy</param> /// <param name="n">The Node that references the Op</param> /// <returns>A copy of the original Node that references a copy of the original Op</returns> public override Node Visit(RefOp op, Node n) { return(CopyDefault(m_destCmd.CreateRefOp(op.EntitySet, op.Type), n)); }
// <summary> // Copies a RefOp // </summary> // <param name="op"> The Op to Copy </param> // <param name="n"> The Node that references the Op </param> // <returns> A copy of the original Node that references a copy of the original Op </returns> public override Node Visit(RefOp op, Node n) { return CopyDefault(m_destCmd.CreateRefOp(op.EntitySet, op.Type), n); }