private void ConvertSpanPath( ObjectFullSpanRewriter.SpanPathInfo parentInfo, List <string> navPropNames, int pos) { NavigationProperty index = (NavigationProperty)null; if (!parentInfo.DeclaringType.NavigationProperties.TryGetValue(navPropNames[pos], true, out index)) { throw new InvalidOperationException(Strings.ObjectQuery_Span_NoNavProp((object)parentInfo.DeclaringType.FullName, (object)navPropNames[pos])); } if (parentInfo.Children == null) { parentInfo.Children = new Dictionary <NavigationProperty, ObjectFullSpanRewriter.SpanPathInfo>(); } ObjectFullSpanRewriter.SpanPathInfo parentInfo1 = (ObjectFullSpanRewriter.SpanPathInfo)null; if (!parentInfo.Children.TryGetValue(index, out parentInfo1)) { parentInfo1 = new ObjectFullSpanRewriter.SpanPathInfo(ObjectFullSpanRewriter.EntityTypeFromResultType(index)); parentInfo.Children[index] = parentInfo1; } if (pos >= navPropNames.Count - 1) { return; } this.ConvertSpanPath(parentInfo1, navPropNames, pos + 1); }
internal override ObjectSpanRewriter.SpanTrackingInfo CreateEntitySpanTrackingInfo( DbExpression expression, EntityType entityType) { ObjectSpanRewriter.SpanTrackingInfo spanTrackingInfo = new ObjectSpanRewriter.SpanTrackingInfo(); ObjectFullSpanRewriter.SpanPathInfo spanPathInfo = this._currentSpanPath.Peek(); if (spanPathInfo.Children != null) { int index = 1; foreach (KeyValuePair <NavigationProperty, ObjectFullSpanRewriter.SpanPathInfo> child in spanPathInfo.Children) { if (spanTrackingInfo.ColumnDefinitions == null) { spanTrackingInfo = this.InitializeTrackingInfo(this.RelationshipSpan); } DbExpression expression1 = (DbExpression)expression.Property(child.Key); this._currentSpanPath.Push(child.Value); DbExpression dbExpression = this.Rewrite(expression1); this._currentSpanPath.Pop(); spanTrackingInfo.ColumnDefinitions.Add(new KeyValuePair <string, DbExpression>(spanTrackingInfo.ColumnNames.Next(), dbExpression)); AssociationEndMember propertyTargetEnd = this.GetNavigationPropertyTargetEnd(child.Key); spanTrackingInfo.SpannedColumns[index] = propertyTargetEnd; if (this.RelationshipSpan) { spanTrackingInfo.FullSpannedEnds[propertyTargetEnd] = true; } ++index; } } return(spanTrackingInfo); }
internal ObjectFullSpanRewriter( DbCommandTree tree, DbExpression toRewrite, Span span, AliasGenerator aliasGenerator) : base(tree, toRewrite, aliasGenerator) { EntityType entityType = (EntityType)null; if (!ObjectFullSpanRewriter.TryGetEntityType(this.Query.ResultType, out entityType)) { throw new InvalidOperationException(Strings.ObjectQuery_Span_IncludeRequiresEntityOrEntityCollection); } ObjectFullSpanRewriter.SpanPathInfo parentInfo = new ObjectFullSpanRewriter.SpanPathInfo(entityType); foreach (Span.SpanPath span1 in span.SpanList) { this.AddSpanPath(parentInfo, span1.Navigations); } this._currentSpanPath.Push(parentInfo); }
private void AddSpanPath( ObjectFullSpanRewriter.SpanPathInfo parentInfo, List <string> navPropNames) { this.ConvertSpanPath(parentInfo, navPropNames, 0); }