Description
openedon Jul 12, 2022
Is your feature request related to a problem? Please describe.
Currently specifying a custom serializer (or serialization settings) is only possible at the CosmosClient
level.
However, we have many scenarios where we need to use different serialization settings for each request.
It's highly encouraged to use single instance clients:
Its recommended to maintain a single instance of CosmosClient per lifetime of the application which enables efficient connection management and performance
Each DocumentClient instance is thread-safe and performs efficient connection management and address caching when operating in direct mode. To allow efficient connection management and better SDK client performance, we recommend that you use a single instance per AppDomain for the lifetime of the application.
While it is possible to use Stream
based APIs for some usages to circumvent this limitation, it is not possible to use with LINQ (GetItemLinqQueryable
) which is our primary API.
Describe the solution you'd like
Allow changing the custom serializer / settings after the client is created. Either of these would work well for our scenarios:
CosmosClient.WithSerializer(CosmosSerializer, CosmosSerializerOptions)
- returns a new instance of the client that utilizes the same connection but with a different serializerCosmosClient.GetContainer(CosmosSerializer, CosmosSerializerOptions)
- same as above, but at the container level
Describe alternatives you've considered
Use multiple CosmosClient
instances.
Metadata
Assignees
Labels
Type
Projects
Status
Triage