public override void Handle(NavigationPropertySegment segment) { var sourceType = this.modelContext.GetEntityTypeOrThrow(segment.NavigationProperty.DeclaringType.As <IEdmEntityType>().Name); INavigationProperty navigationProperty; if (!sourceType.TryGetNavigationProperty(segment.NavigationProperty.Name, out navigationProperty)) { throw new KeyNotFoundException("Navigation property " + segment.NavigationProperty.Name + " not found on type " + sourceType.Name); } if (navigationProperty.IsCollection()) { // we don't handle the collection navigation property immediately but set it to pending as the next segment might be a key this.SetPendingEntityCollection(navigationProperty); } else { if (this.pendingEntityCollection != null) { this.HandlePendingEntityCollection(); } EntityReadingHelper.ReadSingleNavigationProperty(this.readContext, navigationProperty); } }
private void HandlePendingEntityCollection() { var navigationProperty = this.pendingEntityCollection as INavigationProperty; if (navigationProperty != null) { EntityReadingHelper.ReadCollectionNavigationProperty(this.readContext, navigationProperty); } else { EntityReadingHelper.ReadEntitySet(this.readContext, this.pendingEntityCollection.As <IEntitySet>()); } this.pendingEntityCollection = null; }
private void HandlePendingEntityCollection(IEnumerable <KeyValuePair <string, object> > keys) { var navigationProperty = this.pendingEntityCollection as INavigationProperty; if (navigationProperty != null) { var deserializedKeys = GetDeserializedKeys(keys, navigationProperty.TargetType); EntityReadingHelper.ReadCollectionNavigationProperty(this.readContext, navigationProperty, deserializedKeys); } else { var entitySet = this.pendingEntityCollection.As <IEntitySet>(); var deserializedKeys = GetDeserializedKeys(keys, entitySet.EntityType); EntityReadingHelper.ReadEntitySet(this.readContext, entitySet, deserializedKeys); } this.pendingEntityCollection = null; }
public override void Handle(SingletonSegment segment) { EntityReadingHelper.ReadSingleton(this.readContext, this.modelContext.GetEntitySetOrThrow(segment.Singleton.Name)); }