public override void Visit(NewEntityOp op, Node n)
 {
     base.Visit(op, n);
     if (m_compilerState.Phase > PlanCompilerPhase.PreProcessor && op.Type.EdmType.BuiltInTypeKind == md.BuiltInTypeKind.EntityType)
     {
         Assert(op.Scoped, "NewEntityOp for an entity type {0} is not scoped. All entity type constructors must be scoped after PreProcessor phase.", op.Type.EdmType.FullName);
     }
 }
예제 #2
0
        /// <summary>
        /// Copies a NewEntityOp
        /// </summary>
        /// <param name="op">the NewEntityOp to copy</param>
        /// <param name="n">node tree corresponding to the NewEntityOp</param>
        /// <returns>a copy of the node tree</returns>
        public override Node Visit(NewEntityOp op, Node n)
        {
            NewEntityOp opCopy;

            if (op.Scoped)
            {
                opCopy = m_destCmd.CreateScopedNewEntityOp(op.Type, op.RelationshipProperties, op.EntitySet);
            }
            else
            {
                Debug.Assert(op.EntitySet == null, "op.EntitySet must be null for the constructor that hasn't been scoped yet.");
                opCopy = m_destCmd.CreateNewEntityOp(op.Type, op.RelationshipProperties);
            }
            return(CopyDefault(opCopy, n));
        }
 /// <summary>
 ///     Handler for NewEntity
 /// </summary>
 /// <param name="op"> </param>
 /// <param name="n"> </param>
 /// <returns> </returns>
 public override Node Visit(NewEntityOp op, Node n)
 {
     return FlattenConstructor(op, n);
 }
예제 #4
0
        public override Node Visit(NewEntityOp op, Node n)
        {
            // If this is not an entity type constructor, or it's been already scoped, 
            // then just do the default processing.
            if (op.Scoped
                || op.Type.EdmType.BuiltInTypeKind != BuiltInTypeKind.EntityType)
            {
                return base.Visit(op, n);
            }

            var entityType = (EntityType)op.Type.EdmType;
            var scope = GetCurrentEntityTypeScope();

            List<RelProperty> relProperties;
            List<Node> newChildren;

            if (scope == null)
            {
                m_freeFloatingEntityConstructorTypes.Add(entityType);

                // SQLBUDT #546546: Qmv/Umv tests Assert and throws in plan compiler in association tests.
                // If this Entity constructor is not within a view then there should not be any RelProps
                // specified on the NewEntityOp - the eSQL WITH RELATIONSHIP clauses that would cause such
                // RelProps to be added is only enabled when parsing in the user or generated view mode.
                PlanCompiler.Assert(
                    op.RelationshipProperties == null ||
                    op.RelationshipProperties.Count == 0,
                    "Related Entities cannot be specified for Entity constructors that are not part of the Query Mapping View for an Entity Set.");

                // Default processing.
                VisitScalarOpDefault(op, n);

                relProperties = op.RelationshipProperties;
                newChildren = n.Children;
            }
            else
            {
                //
                // Note: We don't do the default processing first to avoid adding references to types and entity sets
                // that may only be used in pre-built rel property expressions that may not be needed.
                //

                // 
                // Find the relationship properties for this entitytype (and entity set)
                //
                relProperties = new List<RelProperty>(m_relPropertyHelper.GetRelProperties(entityType));

                // Remove pre-built rel property expressions that would not be needed to avoid 
                // unnecessary adding references to types and entity sets during default processing
                var j = op.RelationshipProperties.Count - 1;
                var copiedRelPropList = new List<RelProperty>(op.RelationshipProperties);
                for (var i = n.Children.Count - 1; i >= entityType.Properties.Count; i--, j--)
                {
                    if (!relProperties.Contains(op.RelationshipProperties[j]))
                    {
                        n.Children.RemoveAt(i);
                        copiedRelPropList.RemoveAt(j);
                    }
                }

                // Default processing.
                VisitScalarOpDefault(op, n);

                //
                // Ok, now, I have to build out some relationship properties that 
                // haven't been specified
                //
                var keyExpr = BuildKeyExpressionForNewEntityOp(op, n);

                // 
                // Find the list of rel properties that have already been specified
                // 
                var prebuiltRelPropertyExprs = new Dictionary<RelProperty, Node>();
                j = 0;
                for (var i = entityType.Properties.Count; i < n.Children.Count; i++, j++)
                {
                    prebuiltRelPropertyExprs[copiedRelPropList[j]] = n.Children[i];
                }

                //
                // Next, rebuild the list of children - includes expressions for each rel property
                //
                newChildren = new List<Node>();
                for (var i = 0; i < entityType.Properties.Count; i++)
                {
                    newChildren.Add(n.Children[i]);
                }

                foreach (var relPropNode in BuildAllRelPropertyExpressions(scope, relProperties, prebuiltRelPropertyExprs, keyExpr))
                {
                    newChildren.Add(relPropNode);
                }
            }

            //
            // Finally, build out the newOp.
            //
            Op newEntityOp = m_command.CreateScopedNewEntityOp(op.Type, relProperties, scope);
            var newNode = m_command.CreateNode(newEntityOp, newChildren);
            return newNode;
        }
예제 #5
0
 public override void Visit(NewEntityOp op, Node n)
 {
     base.Visit(op, n);
     if (m_compilerState.Phase > PlanCompilerPhase.PreProcessor
         && op.Type.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType)
     {
         Assert(
             op.Scoped,
             "NewEntityOp for an entity type {0} is not scoped. All entity type constructors must be scoped after PreProcessor phase.",
             op.Type.EdmType.FullName);
     }
 }
 /// <summary>
 ///     Visitor pattern method for NewEntityOp
 /// </summary>
 /// <param name="op"> The NewEntityOp being visited </param>
 /// <param name="n"> The Node that references the Op </param>
 public virtual void Visit(NewEntityOp op, Node n)
 {
     VisitScalarOpDefault(op, n);
 }
예제 #7
0
파일: Dump.cs 프로젝트: dox0/DotNet471RS3
 public override void Visit(NewEntityOp op, Node n)
 {
     VisitNewOp(op, n);
 }
예제 #8
0
 // <summary>
 // Copies a NewEntityOp
 // </summary>
 // <param name="op"> the NewEntityOp to copy </param>
 // <param name="n"> node tree corresponding to the NewEntityOp </param>
 // <returns> a copy of the node tree </returns>
 public override Node Visit(NewEntityOp op, Node n)
 {
     NewEntityOp opCopy;
     if (op.Scoped)
     {
         opCopy = m_destCmd.CreateScopedNewEntityOp(op.Type, op.RelationshipProperties, op.EntitySet);
     }
     else
     {
         Debug.Assert(op.EntitySet == null, "op.EntitySet must be null for the constructor that hasn't been scoped yet.");
         opCopy = m_destCmd.CreateNewEntityOp(op.Type, op.RelationshipProperties);
     }
     return CopyDefault(opCopy, n);
 }