-
Notifications
You must be signed in to change notification settings - Fork 225
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
Allow mapping JSON to Dictionary<string,string> #1825
Comments
jsonb
for key
The provider currently doesn't support mapping Keeping open to track mapping |
@roji Any chance there was movement on this since 2021, or a way to implement this? |
@rlightner the main reason I haven't been looking at this is the steady progress on JSON support at the EF side - it would be best to not do something specific here on the PG side but rather to have one holistic approach across EF. For now, you can use value converters to serialize your Dictionary to a JSON document, and then use SQL querying if you need to query inside that document. |
Thanks for the fast response. To clarify:
|
Yep - that should take care of serialization. The only thing this doesn't take care of is querying (e.g. filtering based on the value inside the dictionary). |
I use something like this for Dictionary<string, string>:
|
Note that mapping Dictionaries is not support when using ToJson and Owns (see dotnet/efcore#29825). |
@roji I'm just now getting around to upgrading my project to .NET 8. I see that POCO mapping was deprecated. Am I correct in my understanding that this means I can no longer use [Column(TypeName = "jsonb")] on collections? Is there a way to continue using it for things like this? I was using the [Column(TypeName = "jsonb")] for dictionaries just fine, but due to the deprecation, had to switch most things to ToJson. And now I'm in refactoring hell due to bugs in .NET 8 (e.g. the Id property bug) and missing features in .NET 8 like this dictionary support missing |
The older way of mapping JSON via |
Hello! I have question. I used next entity with
jsonb
type column:I want to use
order by
for example how Postgres SQL script:Is it possible to do this sorting on EF? I searched in the documentation for this, as well as on the vastness of stackoverflow and in issues github, but I did not find an answer to this question.
The text was updated successfully, but these errors were encountered: