-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
How to deal with dictionary items in entity for .ToJson functionality #31257
Comments
@ajcvickers i read the other post regarding primitives and see there was some commits to ef8. Is using the property / conversion the only supported way to do what I need in ef7? Does ef8 support this now to have just a nice array of string,string? |
@MacMcDell EF8 will bring 1st-class support for primitive lists/arrays, but not for dictionaries. In both EF7 and 8, to serialize a dictionary you'll have to use a value converter. |
Thanks for getting back to me. So the current method I'm using where I
serialize manually in and out is pretty much the recommended way? Ie...
This.property.hasconversion(in,out)...
…On Sun, 16 Jul 2023, 08:05 Shay Rojansky, ***@***.***> wrote:
@MacMcDell <https://github.com/MacMcDell> EF8 will bring 1st-class
support for primitive lists/arrays, but not for dictionaries. In both EF7
and 8, to serialize a dictionary you'll have to use a value converter.
—
Reply to this email directly, view it on GitHub
<#31257 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALRK5NQKQPDQE6MLIODXVLXQP7L3ANCNFSM6AAAAAA2JAISXU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yes. |
Duplicate of #29825 |
@ajcvickers it's not a weakly-typed mapping. Seems like I ran into the same issue with strongly typed |
How to deal with dictionary items in Json?
I am banging my head against a wall trying to get a dictionary within a poco to behave nicely when storing the data as Json. I am using EFCore 7.08. Why does this seem so difficult to get done? What am I missing to understand here?. MatchSuccess Has/Owns? a property that is a collection.
All I want to get stored is something that looks like reasonable json
example of what I want in db:
vs what I get in db:
As you cannot see... I can easily parse this back out.
setup
I have a very simple POCO like this:
It gets used here:
my builder looks like this:
my serializer options are:
This thing is slowly killing me.
Include provider and version information
EF Core version: 7.08
Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer)
Target framework: .NET 6.0
Operating system: IDE: Rider
The text was updated successfully, but these errors were encountered: