Closed giovanni-ferrari closed 9 months ago
@leminh98 @adityasa Could you take a look at this issue?
this might be related to https://github.com/Azure/azure-cosmos-dotnet-v3/issues/1063
@giovanni-ferrari Similar with additional context in #3280
Hi all, we've merged what we hope will be a solution to this issue by allowing the custom serializer to be used for LINQ translations. This also unblocks having System.Text.Json attributes applied in LINQ queries.
We plan to release this as part of the next preview package, but I also wanted to take this time to confirm these changes meet your needs before finalizing them as part of our public API. If you try the changes out, please follow up in the thread if this update addresses your concerns. If it doesn't, please let us know why.
To use your own custom serializer for LINQ translations you must implement CosmosLinqSerializer
and set it as a custom serializer on the CosmosClient
. There is a sample of this for serialization with System.Text.Json in CosmosLinqSerializer.cs.
Still seems to be broken in the latest 3.81.1 nuget package. Does this fix stil have to be released?
Hi @Barsonax, it will be released in the 3.39.0 package, which should be available within a few days.
Leaving a link to source mentioned in comment above https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos.Samples/Usage/SystemTextJson/CosmosSystemTextJsonSerializer.cs
Is your feature request related to a problem? Please describe. Trying to execute a LINQ query on IOrderedQueriable does not allow to query enums as strings
Describe the solution you'd like
this.container.GetItemLinqQueryable<Order>() .Where(o => o.State == OrderState.Completed)
translates to
{"query":"SELECT VALUE root FROM root WHERE (root[\"state\"] = \"Completed\")"}
instead of{"query":"SELECT VALUE root FROM root WHERE (root[\"state\"] = 1)"}
Additional context It would be possible to allow to add a JsonStringEnumConverter in CosmosLinqSerializerOptions.Converters. or better to use the CosmosSerializer used in CosmosClient