/// <summary> /// Writes the entity collection results to the response message. /// </summary> /// <param name="graph">The entity collection results.</param> /// <param name="type">The type of the entities.</param> /// <param name="messageWriter">The message writer.</param> /// <param name="writeContext">The writing context.</param> public override void WriteObject( object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext) { EntityCollectionResult collectionResult = graph as EntityCollectionResult; if (collectionResult != null) { graph = collectionResult.Query; } base.WriteObject(graph, type, messageWriter, writeContext); }
/// <summary> /// Writes the entity collection results to the response message. /// </summary> /// <param name="graph">The entity collection results.</param> /// <param name="type">The type of the entities.</param> /// <param name="messageWriter">The message writer.</param> /// <param name="writeContext">The writing context.</param> public override void WriteObject( object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext) { EntityCollectionResult collectionResult = graph as EntityCollectionResult; if (collectionResult != null) { graph = collectionResult.Query; type = collectionResult.Type; if (TryWriteAggregationResult(graph, type, messageWriter, writeContext, collectionResult.EdmType)) { return; } } base.WriteObject(graph, type, messageWriter, writeContext); }
/// <summary> /// Writes the entity collection results to the response message. /// </summary> /// <param name="graph">The entity collection results.</param> /// <param name="type">The type of the entities.</param> /// <param name="messageWriter">The message writer.</param> /// <param name="writeContext">The writing context.</param> public override void WriteObject( object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext) { Ensure.NotNull(messageWriter, "messageWriter"); Ensure.NotNull(writeContext, "writeContext"); IEdmEntitySetBase entitySet = writeContext.NavigationSource as IEdmEntitySetBase; if (entitySet == null) { throw new SerializationException(Resources.EntitySetMissingForSerialization); } EntityCollectionResult collectionResult = (EntityCollectionResult)graph; IEdmTypeReference feedType = collectionResult.EdmType; IEdmEntityTypeReference entityType = GetEntityType(feedType); ODataWriter writer = messageWriter.CreateODataFeedWriter(entitySet, entityType.EntityDefinition()); this.WriteObjectInline(collectionResult.Query, feedType, writer, writeContext); }