Table of Contents

Class ODataCollectionSerializer

Namespace
System.Web.Http.OData.Formatter.Serialization
Assembly
System.Web.Http.OData.dll

ODataSerializer for serializing collection of Entities or Complex types or primitives.

public class ODataCollectionSerializer : ODataEdmTypeSerializer
Inheritance
ODataCollectionSerializer
Inherited Members

Constructors

ODataCollectionSerializer(ODataSerializerProvider)

Initializes a new instance of the ODataCollectionSerializer class.

public ODataCollectionSerializer(ODataSerializerProvider serializerProvider)

Parameters

serializerProvider ODataSerializerProvider

The serializer provider to use to serialize nested objects.

Methods

AddTypeNameAnnotationAsNeeded(ODataCollectionValue, ODataMetadataLevel)

Adds the type name annotations required for proper json light serialization.

protected static void AddTypeNameAnnotationAsNeeded(ODataCollectionValue value, ODataMetadataLevel metadataLevel)

Parameters

value ODataCollectionValue

The collection value for which the annotations have to be added.

metadataLevel ODataMetadataLevel

The OData metadata level of the response.

CreateODataCollectionValue(IEnumerable, IEdmTypeReference, ODataSerializerContext)

Creates an Microsoft.Data.OData.ODataCollectionValue for the enumerable represented by enumerable.

public virtual ODataCollectionValue CreateODataCollectionValue(IEnumerable enumerable, IEdmTypeReference elementType, ODataSerializerContext writeContext)

Parameters

enumerable IEnumerable

The value of the collection to be created.

elementType IEdmTypeReference

The element EDM type of the collection.

writeContext ODataSerializerContext

The serializer context to be used while creating the collection.

Returns

ODataCollectionValue

The created Microsoft.Data.OData.ODataCollectionValue.

CreateODataValue(object, IEdmTypeReference, ODataSerializerContext)

public override sealed ODataValue CreateODataValue(object graph, IEdmTypeReference expectedType, ODataSerializerContext writeContext)

Parameters

graph object
expectedType IEdmTypeReference
writeContext ODataSerializerContext

Returns

ODataValue

WriteCollection(ODataCollectionWriter, object, IEdmTypeReference, ODataSerializerContext)

Writes the given graph using the given writer.

public void WriteCollection(ODataCollectionWriter writer, object graph, IEdmTypeReference collectionType, ODataSerializerContext writeContext)

Parameters

writer ODataCollectionWriter

The Microsoft.Data.OData.ODataCollectionWriter to use.

graph object

The collection to write.

collectionType IEdmTypeReference

The EDM type of the collection.

writeContext ODataSerializerContext

The serializer context.

WriteObject(object, Type, ODataMessageWriter, ODataSerializerContext)

public override void WriteObject(object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)

Parameters

graph object
type Type
messageWriter ODataMessageWriter
writeContext ODataSerializerContext