-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query: Adds support for System.Text LINQ Custom Serializer #4138
Query: Adds support for System.Text LINQ Custom Serializer #4138
Conversation
...os/tests/Microsoft.Azure.Cosmos.EmulatorTests/LinqTranslationWithCustomSerializerBaseline.cs
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Serializer/CosmosLinqSerializerOptions.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Linq/DataContractCosmosLinqSerializer.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Linq/DataContractCosmosLinqSerializer.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Linq/DataContractCosmosLinqSerializer.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Serializer/CosmosSerializationUtil.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Linq/DataContractCosmosLinqSerializer.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Matias Quaranta <ealsur@users.noreply.github.com>
Co-authored-by: Matias Quaranta <ealsur@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is this getting released in a non-preview version? |
Is this included in microsoft.azure.cosmos\3.39.0-preview.1? It seems I'm missing something as I'm not able to make it use the I made it use the STJ Attributes in storing and loading data by providing my own custom I've tried to follow this code found in commit 0bd4a26 but I'm not able to find the property My guess is, it is simply not published ¯\(ツ)/¯ |
@onionhammer It will be in the next public release (see #4323). We do not have an ETA for this release yet. |
@HSven1611 It is included in 3.39.0-preview.1. If you're only using |
In version 3.39.0-preview.1 I do see 2 properties of the Internal linqSerializerOptions:
A notable distinction exists between utilizing the default serializer option It would be beneficial for these to be unified to behave equally or at least recognized as equivalent. This is also the case for the Is this possible? Or what is the difference, this would help us make the options more generic. Because this way it still requires a very specific The options I would like to reuse for my CosmosLinqSerializer are:
Workaround for now could be something like:
Nonetheless, addressing the But I understand if this falls under a different request |
Any update on this? Ballpark? This summer? This year? |
@onionhammer we are planning on releasing this within a week. |
@Maya-Painter Could you please provide a basic sample for system text json serializer for linq and default serializer? I tried with 3.39.1 version.
I'm using this Line 817 in dee9aba
I'm not able to figure out how to configure both |
@sreejith-ms the linq serializer inherits from the normal JSON serializer, so it does both functions |
@onionhammer Thanks for the clarification. |
The |
Description
This change allows users to use custom serializers for the translation of LINQ queries.
To use their own custom serializer for LINQ translations users must implement
CosmosLinqSerializer
and set as a custom serializer on theCosmosClient
. (Sample in CosmosLinqSerializer.cs)This allows for the following scenarios:
Property name customization via
JsonPropertyName
Given an object:
With the following query:
query = testContainer.GetItemLinqQueryable<MyItem>().Where(i => i == new MyItem() { ProjectId = "test", Id = "id1"});
This will be translated into the following SQL query, taking into account the property attributes on the MyItem class
{"query":"SELECT VALUE root FROM root WHERE (root = {\"id\": \"id1\", \"project_id\": \"test\"})"}
Enum conversion via
StringEnumConverter
This change also means that the
System.Text.Json.Serialization.StringEnumConverter()
will be honored when translating enums in LINQ queries. IfJsonStringEnumConverter()
is specified as a converter on the custom serializer, enums do not need to be decorated with[JsonConverter(typeof(JsonStringEnumConverter))]
.Type of change
Closing issues
closes #1936,
closes #3207,
closes #2685,
closes #3250,
closes #3697,
closes #1253,
closes #2386,
closes #3280,
closes #3491,
closes #484