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

Polymorphism not supported in ToJson() ? #2996

Closed
thomasgustafsson123 opened this issue Nov 28, 2023 · 2 comments
Closed

Polymorphism not supported in ToJson() ? #2996

thomasgustafsson123 opened this issue Nov 28, 2023 · 2 comments

Comments

@thomasgustafsson123
Copy link

thomasgustafsson123 commented Nov 28, 2023

I have a POCO with a list of base objects, say:

public class POCO
{
    public List<BaseType> Values { get; set; }
}

BaseType and Derived objects are decorated with e.g. [JsonDerivedType(typeof(InheritedType1), 1)]

If I configure my entity with:

        builder
            .Property(b => b.Entity)
            .HasColumnType("jsonb");

all derived properties are written, but with

        builder.OwnsOne(rd => rd.Entity, r =>
        {
            r.ToJson();
            r.OwnsMany(d => d.Values);
        });

only BaseType properties are written

@roji
Copy link
Member

roji commented Nov 28, 2023

Duplicate of dotnet/efcore#27779

@roji roji marked this as a duplicate of dotnet/efcore#27779 Nov 28, 2023
@roji
Copy link
Member

roji commented Nov 28, 2023

This is a limitation on the EF side, not related to the PG provider.

@roji roji closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants