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

Add support for shadow property of IEnumerable<T> with custom conversion of T #15631

Closed
filleellif opened this issue May 6, 2019 · 4 comments
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. customer-reported

Comments

@filleellif
Copy link

Imagine the following:

public class ApplicationDbContext : DbContext
{
    public DbSet<Blog> Blogs { get; set; }
}

public class Blog
{
    public Guid Id { get; set; }
    public IEnumerable<Post> Posts { get; set; }
}

public abstract class Post
{
    Guid Id { get; set; }

    public string PostType { get; set; }
}

public class ConcretePost : Post
{
    public string SomeData { get; set; }
}

I would like to have two tables: Blog and Post. The Post table should simply have 4 columns (Id, BlogId, PostType and Json) - so I want to tell EF to serialize (and deserialize) all Posts on the Blog entity but put it in a seperate table.

So far I have only been able to serialize the entire collection but I would like to serialize them individually.

Can this be achieved as of now or is it a missing feature?

@ajcvickers
Copy link
Contributor

@filleellif I don't believe that this is currently possible (without significant hacking.) It's partially covered by #2919 and #4021, and maybe also #1985.

@lomholdt
Copy link

lomholdt commented May 6, 2019

Thank you @ajcvickers.

@ajcvickers
Copy link
Contributor

We discussed this in triage. It's quite a complicated mapping with several unusual elements. For example, Posts is exposed as a navigation property and Post should behave as an entity type, but the serialization is more like a collection of scalars...except that that collection should be in another table.

This is probably best thought of as an aggregate behavior (#1985) such that Posts is a collection of owned types. However, the storage of those owned types is complex and will probably require other features to be implemented first.

@filleellif
Copy link
Author

Thanks a lot for the response @ajcvickers! I figured it needed a lot of work to achieve this, and it's great to hear that you're considering it for the future.

For now, I've made some workarounds that satisfy my needs but I will follow this for sure!

@ajcvickers ajcvickers added closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. and removed type-enhancement needs-design propose-close area-o/c-mapping labels Nov 10, 2021
@ajcvickers ajcvickers removed this from the Backlog milestone Nov 10, 2021
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. customer-reported
Projects
None yet
Development

No branches or pull requests

4 participants