// <summary> // Creates a nested property ref for a rel-property. Delegates to the function above // </summary> // <param name="p"> the rel-property </param> // <returns> a nested property ref </returns> internal PropertyRef CreateNestedPropertyRef(RelProperty p) { return(CreateNestedPropertyRef(new RelPropertyRef(p))); }
internal RelPropertyRef(RelProperty property) { this.m_property = property; }
private static bool TryMatchEntityTypeConstructor( DbExpression then, Dictionary <EdmProperty, DbExpression> propertyMap, Dictionary <RelProperty, DbExpression> relPropertyMap, Dictionary <EntityType, List <RelProperty> > typeToRelPropertyMap, out EntityType entityType) { if (then.ExpressionKind != DbExpressionKind.NewInstance) { entityType = null; return(false); } var constructor = (DbNewInstanceExpression)then; entityType = (EntityType)constructor.ResultType.EdmType; // process arguments to constructor (must be aligned across all case statements) Debug.Assert(entityType.Properties.Count == constructor.Arguments.Count, "invalid new instance"); for (var j = 0; j < entityType.Properties.Count; j++) { var property = entityType.Properties[j]; var assignment = constructor.Arguments[j]; DbExpression existingAssignment; if (propertyMap.TryGetValue(property, out existingAssignment)) { if (!ExpressionsCompatible(assignment, existingAssignment)) { return(false); } } else { propertyMap.Add(property, assignment); } } // Now handle the rel properties if (constructor.HasRelatedEntityReferences) { List <RelProperty> relPropertyList; if (!typeToRelPropertyMap.TryGetValue(entityType, out relPropertyList)) { relPropertyList = new List <RelProperty>(); typeToRelPropertyMap[entityType] = relPropertyList; } foreach (var relatedRef in constructor.RelatedEntityReferences) { var relProperty = new RelProperty( (RelationshipType)relatedRef.TargetEnd.DeclaringType, relatedRef.SourceEnd, relatedRef.TargetEnd); var assignment = relatedRef.TargetEntityReference; DbExpression existingAssignment; if (relPropertyMap.TryGetValue(relProperty, out existingAssignment)) { if (!ExpressionsCompatible(assignment, existingAssignment)) { return(false); } } else { relPropertyMap.Add(relProperty, assignment); } relPropertyList.Add(relProperty); } } return(true); }
/// <summary> /// Simple constructor /// </summary> /// <param name="property"> the property metadata </param> internal RelPropertyRef(RelProperty property) { m_property = property; }
private static bool TryMatchEntityTypeConstructor( DbExpression then, Dictionary <EdmProperty, DbExpression> propertyMap, Dictionary <RelProperty, DbExpression> relPropertyMap, Dictionary <EntityType, List <RelProperty> > typeToRelPropertyMap, out EntityType entityType) { if (then.ExpressionKind != DbExpressionKind.NewInstance) { entityType = (EntityType)null; return(false); } DbNewInstanceExpression instanceExpression = (DbNewInstanceExpression)then; entityType = (EntityType)instanceExpression.ResultType.EdmType; for (int index = 0; index < entityType.Properties.Count; ++index) { EdmProperty property = entityType.Properties[index]; DbExpression x = instanceExpression.Arguments[index]; DbExpression y; if (propertyMap.TryGetValue(property, out y)) { if (!DiscriminatorMap.ExpressionsCompatible(x, y)) { return(false); } } else { propertyMap.Add(property, x); } } if (instanceExpression.HasRelatedEntityReferences) { List <RelProperty> relPropertyList; if (!typeToRelPropertyMap.TryGetValue(entityType, out relPropertyList)) { relPropertyList = new List <RelProperty>(); typeToRelPropertyMap[entityType] = relPropertyList; } foreach (DbRelatedEntityRef relatedEntityReference in instanceExpression.RelatedEntityReferences) { RelProperty key = new RelProperty((RelationshipType)relatedEntityReference.TargetEnd.DeclaringType, relatedEntityReference.SourceEnd, relatedEntityReference.TargetEnd); DbExpression targetEntityReference = relatedEntityReference.TargetEntityReference; DbExpression y; if (relPropertyMap.TryGetValue(key, out y)) { if (!DiscriminatorMap.ExpressionsCompatible(targetEntityReference, y)) { return(false); } } else { relPropertyMap.Add(key, targetEntityReference); } relPropertyList.Add(key); } } return(true); }
internal PropertyRef CreateNestedPropertyRef(RelProperty p) { return(this.CreateNestedPropertyRef((PropertyRef) new RelPropertyRef(p))); }