Skip to content
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

CosmosSerializer not honored in LINQ queries #1936

Closed
MITIN33 opened this issue Oct 15, 2020 · 8 comments · Fixed by #4138
Closed

CosmosSerializer not honored in LINQ queries #1936

MITIN33 opened this issue Oct 15, 2020 · 8 comments · Fixed by #4138
Labels
customer-reported Issue created by a customer LINQ

Comments

@MITIN33
Copy link

MITIN33 commented Oct 15, 2020

It seems like LINQ queries use CosmosSerializationOptions for serialization of fields, but it does not supports ENUM to String conversion. And If i use CosmosSerilaizer then it is not honored by LINQ queries, is there a workaround without decorating field with [JsonConverter(typeof(StringEnumconverter)] and make LINQ queries work for ENUM fields ?

@ealsur ealsur added customer-reported Issue created by a customer LINQ QUERY labels Oct 15, 2020
@ealsur
Copy link
Member

ealsur commented Oct 15, 2020

@khdang Do you have any comment on this one?

@j82w
Copy link
Contributor

j82w commented Oct 19, 2020

This is a duplicate of #1782

@MITIN33
Copy link
Author

MITIN33 commented Oct 20, 2020

@j82w as mentioned in #1782 - when i try to set both Serilazer and SerializerOption it throws ArgumentException -"'SerializerOptions is not compatible with Serializer. Only one can be set. "'

@j82w
Copy link
Contributor

j82w commented Mar 2, 2021

Please try the 3.17.0 nuget.

@j82w j82w closed this as completed Mar 2, 2021
@j82w j82w reopened this Mar 3, 2021
@j82w
Copy link
Contributor

j82w commented Mar 3, 2021

Sorry for closing this. I got the issues number mixed up. This could be address with a new linq serialization option.

@toseni
Copy link

toseni commented Oct 22, 2021

Any news on this? Still having the same problem as described by question author.

@onionhammer
Copy link
Contributor

@j82w Any update?

@Maya-Painter
Copy link
Contributor

Maya-Painter commented Jan 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issue created by a customer LINQ
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants