/// <summary> /// Determines whether the var or a property of the var (if the var is defined as a NewRecord) /// is defined exclusively over a single group aggregate. If so, it registers it as such with the /// group aggregate var info manager. /// </summary> /// <param name="op"></param> /// <param name="n"></param> public override void Visit(VarDefOp op, Node n) { VisitDefault(n); Node definingNode = n.Child0; Op definingNodeOp = definingNode.Op; GroupAggregateVarInfo referencedVarInfo; Node templateNode; bool isUnnested; if (GroupAggregateVarComputationTranslator.TryTranslateOverGroupAggregateVar(definingNode, true, this._command, this._groupAggregateVarInfoManager, out referencedVarInfo, out templateNode, out isUnnested)) { _groupAggregateVarInfoManager.Add(op.Var, referencedVarInfo, templateNode, isUnnested); } else if (definingNodeOp.OpType == OpType.NewRecord) { NewRecordOp newRecordOp = (NewRecordOp)definingNodeOp; for (int i = 0; i < definingNode.Children.Count; i++) { Node argumentNode = definingNode.Children[i]; if (GroupAggregateVarComputationTranslator.TryTranslateOverGroupAggregateVar(argumentNode, true, this._command, this._groupAggregateVarInfoManager, out referencedVarInfo, out templateNode, out isUnnested)) { _groupAggregateVarInfoManager.Add(op.Var, referencedVarInfo, templateNode, isUnnested, newRecordOp.Properties[i]); } } } }
public override void Visit(VarDefOp op, System.Data.Entity.Core.Query.InternalTrees.Node n) { this.VisitDefault(n); System.Data.Entity.Core.Query.InternalTrees.Node child0 = n.Child0; Op op1 = child0.Op; GroupAggregateVarInfo groupAggregateVarInfo; System.Data.Entity.Core.Query.InternalTrees.Node templateNode; bool isUnnested; if (GroupAggregateVarComputationTranslator.TryTranslateOverGroupAggregateVar(child0, true, this._command, this._groupAggregateVarInfoManager, out groupAggregateVarInfo, out templateNode, out isUnnested)) { this._groupAggregateVarInfoManager.Add(op.Var, groupAggregateVarInfo, templateNode, isUnnested); } else { if (op1.OpType != OpType.NewRecord) { return; } NewRecordOp newRecordOp = (NewRecordOp)op1; for (int index = 0; index < child0.Children.Count; ++index) { if (GroupAggregateVarComputationTranslator.TryTranslateOverGroupAggregateVar(child0.Children[index], true, this._command, this._groupAggregateVarInfoManager, out groupAggregateVarInfo, out templateNode, out isUnnested)) { this._groupAggregateVarInfoManager.Add(op.Var, groupAggregateVarInfo, templateNode, isUnnested, (EdmMember)newRecordOp.Properties[index]); } } } }
/// <summary> /// NullOp /// If the node represents a null of an entity type it 'flattens' it into a new record, /// with at most one non-null value: for the typeIdProperty, if one is needed. /// If the node represents an null of a non-entity type, no special work is done. /// </summary> /// <param name="op"> The NullOp </param> /// <param name="n"> The current subtree </param> /// <returns> the new subtree </returns> public override Node Visit(NullOp op, Node n) { if (!TypeUtils.IsStructuredType(op.Type)) { if (md.TypeSemantics.IsEnumerationType(op.Type)) { op.Type = TypeHelpers.CreateEnumUnderlyingTypeUsage(op.Type); } else if (md.TypeSemantics.IsStrongSpatialType(op.Type)) { op.Type = TypeHelpers.CreateSpatialUnionTypeUsage(op.Type); } return n; } // Find the new type corresponding to the type var typeInfo = m_typeInfo.GetTypeInfo(op.Type); var newFields = new List<md.EdmProperty>(); var newFieldValues = new List<Node>(); // Add a typeid property if we need one if (typeInfo.HasTypeIdProperty) { newFields.Add(typeInfo.TypeIdProperty); var typeIdType = md.Helper.GetModelTypeUsage(typeInfo.TypeIdProperty); newFieldValues.Add(CreateNullConstantNode(typeIdType)); } var newRecordOp = new NewRecordOp(typeInfo.FlattenedTypeUsage, newFields); return m_command.CreateNode(newRecordOp, newFieldValues); }
/// <summary> /// NewRecordOp /// </summary> /// <param name="op"> the newRecordOp </param> /// <param name="n"> corresponding node </param> /// <returns> new subtree </returns> public override Node Visit(NewRecordOp op, Node n) { return FlattenConstructor(op, n); }
/// <summary> /// Copies a record constructor /// </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(NewRecordOp op, Node n) { return(CopyDefault(m_destCmd.CreateNewRecordOp(op.Type), n)); }
/// <summary> /// Visitor pattern method for NewRecordOp /// </summary> /// <param name="op"> The NewRecordOp being visited </param> /// <param name="n"> The Node that references the Op </param> public virtual void Visit(NewRecordOp op, Node n) { VisitScalarOpDefault(op, n); }
public override void Visit(NewRecordOp op, Node n) { VisitNewOp(op, n); }
/// <summary> /// In order to support NewRecordOp we may need to adjust the record type. /// </summary> /// <param name="op"></param> /// <param name="n"></param> /// <returns></returns> public override Node Visit(NewRecordOp op, Node n) { return null; }
// <summary> // Copies a record constructor // </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(NewRecordOp op, Node n) { return CopyDefault(m_destCmd.CreateNewRecordOp(op.Type), n); }