Table of Contents

Class CosmosEntitySerializer

Namespace
eQuantic.Core.Data.CosmosDb
Assembly
eQuantic.Core.Data.CosmosDb.dll

The provider's document serializer: System.Text.Json with web (camelCase) defaults, plus the store-neutral modeling vocabulary — [StoredAs] renames the element, [Unmapped] keeps the member out of the document, and the model's Converts registrations translate values both ways. It extends CosmosLinqSerializer so the SDK's LINQ translation asks this serializer for member names: a renamed member filters, sorts and projects against its stored name — the query can never desynchronize from the document.

public sealed class CosmosEntitySerializer : CosmosLinqSerializer
Inheritance
CosmosEntitySerializer
Inherited Members

Constructors

CosmosEntitySerializer(JsonSerializerOptions)

Initializes the serializer over the given options (see CosmosClientFactory).

public CosmosEntitySerializer(JsonSerializerOptions options)

Parameters

options JsonSerializerOptions

The System.Text.Json options.

Methods

BuildOptions(CosmosModel?)

Builds the provider's serializer options: web defaults, the modeling-annotation contract (renames and exclusions), and the model's value converters when a model is given.

public static JsonSerializerOptions BuildOptions(CosmosModel? model = null)

Parameters

model CosmosModel

The Cosmos model whose Converts registrations apply, or null.

Returns

JsonSerializerOptions

FromStream<T>(Stream)

Convert a Stream of JSON to an object. The implementation is responsible for Disposing of the stream, including when an exception is thrown, to avoid memory leaks.

public override T FromStream<T>(Stream stream)

Parameters

stream Stream

The Stream response containing JSON from Cosmos DB.

Returns

T

The object deserialized from the stream.

Type Parameters

T

Any type passed to Container.

SerializeMemberName(MemberInfo)

The element name the SDK's LINQ translation uses for memberInfo.

public override string SerializeMemberName(MemberInfo memberInfo)

Parameters

memberInfo MemberInfo

Returns

string

ToStream<T>(T)

Convert the object to a Stream. The caller will take ownership of the stream and ensure it is correctly disposed of. Stream.CanRead must be true.

public override Stream ToStream<T>(T input)

Parameters

input T

Any type passed to Container.

Returns

Stream

A readable Stream containing JSON of the serialized object.

Type Parameters

T