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

Polymorphic collection in efcore 5 #25472

Closed
arkum opened this issue Aug 10, 2021 · 2 comments
Closed

Polymorphic collection in efcore 5 #25472

arkum opened this issue Aug 10, 2021 · 2 comments

Comments

@arkum
Copy link

arkum commented Aug 10, 2021

Wondering whether it is possible to achieve the below with efcore 5

public class Booking
{
    public Guid Id {get;set}

    public BookingType BookingType {get;set;}

   public ICollection<BookingDetail> BookingDetails {get;set;}

}

BookingDetail is an abstract class
There are different types of Booking Details

public class PoolGroupBooking : BookingDetail
{
}
public class DriveupBooking : BookingDetail
{
}

I want BookingDetails collection to be populated with the object of the appropriate derived type, based on BookingType column

I would like to use TPH for storing the different attributes of BookingDetail into one BookingDetail table. However, the discriminator is in the parent table Booking

  • Can i use polymorphic collections where the BookingDetails property gets filled with the appropriate concrete type based on the BookingType property
  • Can i use a column from a different table as a discriminator

Include provider and version information

EF Core version:5.0
Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (e.g. .NET 5.0)
Operating system:
IDE: (e.g. Visual Studio 2019 16.3)

@ajcvickers
Copy link
Member

Note for triage: Possibly related to #7623

@ajcvickers
Copy link
Member

Note from triage: we believe this is covered by #7623. Please vote for that issue.

@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
Projects
None yet
Development

No branches or pull requests

2 participants