// <summary> // Add a new property reference to this list // </summary> // <param name="property"> new property reference </param> internal void Add(PropertyRef property) { if (m_allProperties) { return; } else if (property is AllPropertyRef) { MakeAllProperties(); } else { m_propertyReferences[property] = property; } }
// <summary> // Add a mapping from the propertyRef (of the old type) to the // corresponding property in the new type. // NOTE: Only to be used by StructuredTypeInfo // </summary> internal void AddPropertyMapping(PropertyRef propertyRef, EdmProperty newProperty) { m_propertyMap[propertyRef] = newProperty; if (propertyRef is TypeIdPropertyRef) { m_typeIdProperty = newProperty; } else if (propertyRef is EntitySetIdPropertyRef) { m_entitySetIdProperty = newProperty; } else if (propertyRef is NullSentinelPropertyRef) { m_nullSentinelProperty = newProperty; } }
internal int GetNestedStructureOffset(PropertyRef property) { // m_propertyRefList contains every element of the flattened type for (var i = 0; i < m_propertyRefList.Count; i++) { var nestedPropertyRef = m_propertyRefList[i] as NestedPropertyRef; // match offset of the first element of the complex type property if (null != nestedPropertyRef && nestedPropertyRef.InnerProperty.Equals(property)) { return(i); } } PlanCompiler.Assert(false, "no complex structure " + property + " found in TypeInfo"); // return something so that the compiler doesn't complain return(default(int)); }
internal void AddPropertyMapping(PropertyRef propertyRef, EdmProperty newProperty) { this.m_propertyMap[propertyRef] = newProperty; if (propertyRef is TypeIdPropertyRef) { this.m_typeIdProperty = newProperty; } else if (propertyRef is EntitySetIdPropertyRef) { this.m_entitySetIdProperty = newProperty; } else { if (!(propertyRef is NullSentinelPropertyRef)) { return; } this.m_nullSentinelProperty = newProperty; } }
/// <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) { var cdProps = new PropertyRefList(); if (!TypeUtils.IsStructuredType(op.Type)) { cdProps.Add(propertyRef); } else { // Get the list of properties my parent expects from me. var 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 (var p in pdProps.Properties) { cdProps.Add(p.CreateNestedPropertyRef(propertyRef)); } } } // push down my expectations AddPropertyRefs(n.Child0, cdProps); VisitChildren(n); }
private TypeUsage GetPropertyType(RootTypeInfo typeInfo, PropertyRef p) { TypeUsage type = (TypeUsage)null; PropertyRef propertyRef = (PropertyRef)null; while (p is NestedPropertyRef) { NestedPropertyRef nestedPropertyRef = (NestedPropertyRef)p; p = nestedPropertyRef.OuterProperty; propertyRef = nestedPropertyRef.InnerProperty; } if (p is TypeIdPropertyRef) { SimplePropertyRef simplePropertyRef = (SimplePropertyRef)propertyRef; type = simplePropertyRef == null ? typeInfo.TypeIdType : this.GetTypeInfo(simplePropertyRef.Property.TypeUsage).RootType.TypeIdType; } else if (p is EntitySetIdPropertyRef || p is NullSentinelPropertyRef) { type = this.m_intType; } else if (p is RelPropertyRef) { type = ((RelPropertyRef)p).Property.ToEnd.TypeUsage; } else { SimplePropertyRef simplePropertyRef = p as SimplePropertyRef; if (simplePropertyRef != null) { type = Helper.GetModelTypeUsage(simplePropertyRef.Property); } } TypeUsage newType = this.GetNewType(type); System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Assert(null != newType, "unrecognized property type?"); return(newType); }
// <summary> // Adds a new property reference to the list of desired properties // NOTE: Only to be used by StructuredTypeInfo // </summary> internal void AddPropertyRef(PropertyRef propertyRef) { m_propertyRefList.Add(propertyRef); }
private void VisitPropertyOp(Op op, System.Data.Entity.Core.Query.InternalTrees.Node n, PropertyRef propertyRef) { PropertyRefList propertyRefs = new PropertyRefList(); if (!TypeUtils.IsStructuredType(op.Type)) { propertyRefs.Add(propertyRef); } else { PropertyRefList propertyRefList = this.GetPropertyRefList(n); if (propertyRefList.AllProperties) { propertyRefs = propertyRefList; } else { foreach (PropertyRef property in propertyRefList.Properties) { propertyRefs.Add(property.CreateNestedPropertyRef(propertyRef)); } } } this.AddPropertyRefs(n.Child0, propertyRefs); this.VisitChildren(n); }
// <summary> // Do I contain the specifed property? // </summary> // <param name="p"> The property </param> // <returns> true, if I do </returns> internal bool Contains(PropertyRef p) { return m_allProperties || m_propertyReferences.ContainsKey(p); }
// <summary> // Create a nested property ref, with "p" as the prefix. // The best way to think of this function as follows. // Consider a type T where "this" describes a property X on T. Now // consider a new type S, where "p" is a property of S and is of type T. // This function creates a PropertyRef that describes the same property X // from S.p instead // </summary> // <param name="p"> the property to prefix with </param> // <returns> the nested property reference </returns> internal virtual PropertyRef CreateNestedPropertyRef(PropertyRef p) { return(new NestedPropertyRef(p, this)); }
internal NestedPropertyRef(PropertyRef innerProperty, PropertyRef outerProperty) { System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Assert(!(innerProperty is NestedPropertyRef), "innerProperty cannot be a NestedPropertyRef"); this.m_inner = innerProperty; this.m_outer = outerProperty; }
private Node VisitPropertyOp(Op op, Node n, PropertyRef propertyRef, bool throwIfMissing) { PlanCompiler.Assert( op.OpType == OpType.Property || op.OpType == OpType.RelProperty, "Unexpected optype: " + op.OpType); var inputType = n.Child0.Op.Type; var outputType = op.Type; // First visit all my children VisitChildren(n); Node newNode = null; var inputTypeInfo = m_typeInfo.GetTypeInfo(inputType); if (TypeUtils.IsStructuredType(outputType)) { var outputTypeInfo = m_typeInfo.GetTypeInfo(outputType); var fieldTypes = new List<md.EdmProperty>(); var fieldValues = new List<Node>(); var expectedProperties = m_nodePropertyMap[n]; foreach (var npr in outputTypeInfo.PropertyRefList) { // Is this a property that's desired by my consumers? if (expectedProperties.Contains(npr)) { var newPropRef = npr.CreateNestedPropertyRef(propertyRef); md.EdmProperty newNestedProp; if (inputTypeInfo.TryGetNewProperty(newPropRef, throwIfMissing, out newNestedProp)) { var outputNestedProp = outputTypeInfo.GetNewProperty(npr); var field = BuildAccessor(n.Child0, newNestedProp); if (null != field) { fieldTypes.Add(outputNestedProp); fieldValues.Add(field); } } } } Op newRecordOp = m_command.CreateNewRecordOp(outputTypeInfo.FlattenedTypeUsage, fieldTypes); newNode = m_command.CreateNode(newRecordOp, fieldValues); } else { var newProp = inputTypeInfo.GetNewProperty(propertyRef); // Build an accessor over the new property newNode = BuildAccessorWithNulls(n.Child0, newProp); } return newNode; }
/// <summary> /// Create a nested property ref, with "p" as the prefix. /// The best way to think of this function as follows. /// Consider a type T where "this" describes a property X on T. Now /// consider a new type S, where "p" is a property of S and is of type T. /// This function creates a PropertyRef that describes the same property X /// from S.p instead /// </summary> /// <param name="p"> the property to prefix with </param> /// <returns> the nested property reference </returns> internal virtual PropertyRef CreateNestedPropertyRef(PropertyRef p) { return new NestedPropertyRef(p, this); }
// <summary> // Try get the new property for the supplied propertyRef // </summary> // <param name="propertyRef"> property reference (on the old type) </param> // <param name="throwIfMissing"> throw if the property is not found </param> // <param name="newProperty"> the corresponding property on the new type </param> internal bool TryGetNewProperty(PropertyRef propertyRef, bool throwIfMissing, out md.EdmProperty newProperty) { return(RootType.TryGetNewProperty(propertyRef, throwIfMissing, out newProperty)); }
/// <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) { var cdProps = new PropertyRefList(); if (!TypeUtils.IsStructuredType(op.Type)) { cdProps.Add(propertyRef); } else { // Get the list of properties my parent expects from me. var 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 (var p in pdProps.Properties) { cdProps.Add(p.CreateNestedPropertyRef(propertyRef)); } } } // push down my expectations AddPropertyRefs(n.Child0, cdProps); VisitChildren(n); }
private md.TypeUsage GetPropertyType(RootTypeInfo typeInfo, PropertyRef p) { md.TypeUsage result = null; PropertyRef innerProperty = null; // Get the "leaf" property first while (p is NestedPropertyRef) { var npr = (NestedPropertyRef)p; p = npr.OuterProperty; innerProperty = npr.InnerProperty; } if (p is TypeIdPropertyRef) { // // Get to the innermost type that specifies this typeid (the entity type), // get the datatype for the typeid column from that type // var simplePropertyRef = (SimplePropertyRef)innerProperty; if (simplePropertyRef != null) { var innerType = simplePropertyRef.Property.TypeUsage; var innerTypeInfo = GetTypeInfo(innerType); result = innerTypeInfo.RootType.TypeIdType; } else { result = typeInfo.TypeIdType; } } else if (p is EntitySetIdPropertyRef || p is NullSentinelPropertyRef) { result = m_intType; } else if (p is RelPropertyRef) { result = ((RelPropertyRef)p).Property.ToEnd.TypeUsage; } else { var simpleP = p as SimplePropertyRef; if (simpleP != null) { result = md.Helper.GetModelTypeUsage(simpleP.Property); } } result = GetNewType(result); PlanCompiler.Assert(null != result, "unrecognized property type?"); return result; }
internal NestedPropertyRef(PropertyRef innerProperty, PropertyRef outerProperty) { PlanCompiler.Assert(!(innerProperty is NestedPropertyRef), "innerProperty cannot be a NestedPropertyRef"); m_inner = innerProperty; m_outer = outerProperty; }
internal NestedPropertyRef(PropertyRef innerProperty, PropertyRef outerProperty) { PlanCompiler.Assert(!(innerProperty is NestedPropertyRef), "innerProperty cannot be a NestedPropertyRef"); m_inner = innerProperty; m_outer = outerProperty; }
internal int GetNestedStructureOffset(PropertyRef property) { // m_propertyRefList contains every element of the flattened type for (var i = 0; i < m_propertyRefList.Count; i++) { var nestedPropertyRef = m_propertyRefList[i] as NestedPropertyRef; // match offset of the first element of the complex type property if (null != nestedPropertyRef && nestedPropertyRef.InnerProperty.Equals(property)) { return i; } } PlanCompiler.Assert(false, "no complex structure " + property + " found in TypeInfo"); // return something so that the compiler doesn't complain return default(int); }
internal new bool TryGetNewProperty(PropertyRef propertyRef, bool throwIfMissing, out EdmProperty property) { var result = m_propertyMap.TryGetValue(propertyRef, out property); if (throwIfMissing && !result) { { PlanCompiler.Assert(false, "Unable to find property " + propertyRef + " in type " + Type.EdmType.Identity); } } return result; }
/// <summary> /// Get the new property for the supplied propertyRef /// </summary> /// <param name="propertyRef"> property reference (on the old type) </param> /// <returns> </returns> internal md.EdmProperty GetNewProperty(PropertyRef propertyRef) { md.EdmProperty property; var result = TryGetNewProperty(propertyRef, true, out property); Debug.Assert(result, "Should have thrown if the property was not found"); return property; }
// <summary> // Adds a new property reference to the list of desired properties // NOTE: Only to be used by StructuredTypeInfo // </summary> internal void AddPropertyRef(PropertyRef propertyRef) { m_propertyRefList.Add(propertyRef); }
/// <summary> /// Try get the new property for the supplied propertyRef /// </summary> /// <param name="propertyRef"> property reference (on the old type) </param> /// <param name="throwIfMissing"> throw if the property is not found </param> /// <param name="newProperty"> the corresponding property on the new type </param> /// <returns> </returns> internal bool TryGetNewProperty(PropertyRef propertyRef, bool throwIfMissing, out md.EdmProperty newProperty) { return RootType.TryGetNewProperty(propertyRef, throwIfMissing, out newProperty); }
/// <summary> /// Is the given propertyRef representing a null sentinel /// It is if: /// - it is a NullSentinelPropertyRef /// - it is a NestedPropertyRef with the outer property being a NullSentinelPropertyRef /// </summary> /// <param name="propertyRef"> </param> /// <returns> </returns> private static bool IsNullSentinelPropertyRef(PropertyRef propertyRef) { if (propertyRef is NullSentinelPropertyRef) { return true; } var nestedPropertyRef = propertyRef as NestedPropertyRef; if (nestedPropertyRef == null) { return false; } return nestedPropertyRef.OuterProperty is NullSentinelPropertyRef; }
// <summary> // Do I contain the specifed property? // </summary> // <param name="p"> The property </param> // <returns> true, if I do </returns> internal bool Contains(PropertyRef p) { return(m_allProperties || m_propertyReferences.ContainsKey(p)); }