/// <summary>
        /// Gets the list of "identity" properties for an entity. Gets the
        /// "entitysetid" property in addition to the "key" properties
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        private static PropertyRefList GetIdentityProperties(md.EntityType type)
        {
            PropertyRefList desiredProperties = GetKeyProperties(type);

            desiredProperties.Add(EntitySetIdPropertyRef.Instance);
            return(desiredProperties);
        }
        /// <summary>
        /// IsOfOp handling
        ///
        /// Simply requests the "typeid" property from
        /// the input. No other property is required
        /// </summary>
        /// <param name="op">IsOf op</param>
        /// <param name="n">Node to visit</param>
        public override void Visit(IsOfOp op, Node n)
        {
            // The only property I need from my child is the typeid property;
            PropertyRefList childProps = new PropertyRefList();

            childProps.Add(TypeIdPropertyRef.Instance);
            AddPropertyRefs(n.Child0, childProps);

            VisitChildren(n);
        }
        /// <summary>
        /// Create a clone of myself
        /// </summary>
        /// <returns>a clone of myself</returns>
        internal PropertyRefList Clone()
        {
            PropertyRefList newProps = new PropertyRefList(m_allProperties);

            foreach (PropertyRef p in this.m_propertyReferences.Keys)
            {
                newProps.Add(p);
            }
            return(newProps);
        }
        /// <summary>
        /// Common handler for RelPropertyOp and PropertyOp.
        /// Simply pushes down the desired set of properties to the child
        /// </summary>
        /// <param name="op">the *propertyOp</param>
        /// <param name="n">node tree corresponding to the Op</param>
        /// <param name="propertyRef">the property reference</param>
        private void VisitPropertyOp(Op op, Node n, PropertyRef propertyRef)
        {
            PropertyRefList cdProps = new PropertyRefList();

            if (!TypeUtils.IsStructuredType(op.Type))
            {
                cdProps.Add(propertyRef);
            }
            else
            {
                // Get the list of properties my parent expects from me.
                PropertyRefList pdProps = GetPropertyRefList(n);

                // Ask my child (which is really my container type) for each of these
                // properties

                // If I've been asked for all my properties, then get the
                // corresponding flat list of properties from my children.
                // For now, however, simply ask for all properties in this case
                // What we really need to do is to get the "flattened" list of
                // properties from the input, and prepend each of these with
                // our property name. We don't have that info available, so
                // I'm taking the easier route.
                if (pdProps.AllProperties)
                {
                    cdProps = pdProps;
                }
                else
                {
                    foreach (PropertyRef p in pdProps.Properties)
                    {
                        cdProps.Add(p.CreateNestedPropertyRef(propertyRef));
                    }
                }
            }

            // push down my expectations
            AddPropertyRefs(n.Child0, cdProps);
            VisitChildren(n);
        }
        /// <summary>
        /// TreatOp handling
        ///
        /// Simply passes down "my" desired properties, and additionally
        /// asks for the TypeID property
        /// </summary>
        /// <param name="op"></param>
        /// <param name="n"></param>
        public override void Visit(TreatOp op, Node n)
        {
            // First find the properties that my parent expects from me
            PropertyRefList pdProps = GetPropertyRefList(n);

            // Push down each of these, and in addition, push down the typeid property
            // to my child
            PropertyRefList childProps = pdProps.Clone();

            childProps.Add(TypeIdPropertyRef.Instance);
            AddPropertyRefs(n.Child0, childProps);
            VisitChildren(n);
        }
        /// <summary>
        /// Gets the list of key properties for an entity
        /// </summary>
        /// <param name="entityType"></param>
        /// <returns></returns>
        private static PropertyRefList GetKeyProperties(md.EntityType entityType)
        {
            PropertyRefList desiredProperties = new PropertyRefList();

            foreach (md.EdmMember p in entityType.KeyMembers)
            {
                md.EdmProperty edmP = p as md.EdmProperty;
                PlanCompiler.Assert(edmP != null, "EntityType had non-EdmProperty key member?");
                SimplePropertyRef pRef = new SimplePropertyRef(edmP);
                desiredProperties.Add(pRef);
            }
            return(desiredProperties);
        }
 /// <summary>
 /// Create a clone of myself
 /// </summary>
 /// <returns>a clone of myself</returns>
 internal PropertyRefList Clone()
 {
     PropertyRefList newProps = new PropertyRefList(m_allProperties);
     foreach (PropertyRef p in this.m_propertyReferences.Keys)
         newProps.Add(p);
     return newProps;
 }
        /// <summary>
        /// Common handler for RelPropertyOp and PropertyOp. 
        /// Simply pushes down the desired set of properties to the child
        /// </summary>
        /// <param name="op">the *propertyOp</param>
        /// <param name="n">node tree corresponding to the Op</param>
        /// <param name="propertyRef">the property reference</param>
        private void VisitPropertyOp(Op op, Node n, PropertyRef propertyRef)
        {
            PropertyRefList cdProps = new PropertyRefList();
            if (!TypeUtils.IsStructuredType(op.Type))
            {
                cdProps.Add(propertyRef);
            }
            else
            {
                // Get the list of properties my parent expects from me. 
                PropertyRefList pdProps = GetPropertyRefList(n);

                // Ask my child (which is really my container type) for each of these 
                // properties

                // If I've been asked for all my properties, then get the 
                // corresponding flat list of properties from my children.
                // For now, however, simply ask for all properties in this case
                // What we really need to do is to get the "flattened" list of
                // properties from the input, and prepend each of these with
                // our property name. We don't have that info available, so 
                // I'm taking the easier route.
                if (pdProps.AllProperties)
                {
                    cdProps = pdProps;
                }
                else
                {
                    foreach (PropertyRef p in pdProps.Properties)
                    {
                        cdProps.Add(p.CreateNestedPropertyRef(propertyRef));
                    }
                }
            }

            // push down my expectations
            AddPropertyRefs(n.Child0, cdProps);
            VisitChildren(n);
        }
        /// <summary>
        /// IsOfOp handling
        /// 
        /// Simply requests the "typeid" property from
        /// the input. No other property is required
        /// </summary>
        /// <param name="op">IsOf op</param>
        /// <param name="n">Node to visit</param>
        public override void Visit(IsOfOp op, Node n)
        {

            // The only property I need from my child is the typeid property;
            PropertyRefList childProps = new PropertyRefList();
            childProps.Add(TypeIdPropertyRef.Instance);
            AddPropertyRefs(n.Child0, childProps);

            VisitChildren(n);
        }
 /// <summary>
 /// Gets the list of key properties for an entity
 /// </summary>
 /// <param name="entityType"></param>
 /// <returns></returns>
 private static PropertyRefList GetKeyProperties(md.EntityType entityType)
 {
     PropertyRefList desiredProperties = new PropertyRefList();
     foreach (md.EdmMember p in entityType.KeyMembers)
     {
         md.EdmProperty edmP = p as md.EdmProperty;
         PlanCompiler.Assert(edmP != null, "EntityType had non-EdmProperty key member?");
         SimplePropertyRef pRef = new SimplePropertyRef(edmP);
         desiredProperties.Add(pRef);
     }
     return desiredProperties;
 }
 /// <summary>
 /// Create a clone of myself
 /// </summary>
 /// <returns>a clone of myself</returns>
 internal PropertyRefList Clone()
 {
     var newProps = new PropertyRefList(m_allProperties);
     foreach (var p in m_propertyReferences.Keys)
     {
         newProps.Add(p);
     }
     return newProps;
 }