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

include navigation with inherit class #6215

Closed
hi-xiaoxin opened this issue Aug 1, 2016 · 2 comments
Closed

include navigation with inherit class #6215

hi-xiaoxin opened this issue Aug 1, 2016 · 2 comments

Comments

@hi-xiaoxin
Copy link

hi-xiaoxin commented Aug 1, 2016

hi :

i have three classes like this:

class ClassBase { ...} 
class ClassA {  ClassOther1 NavigationA }
class ClassB {  ClassOther2 NavigationB }

in EFCore , I build model like this:

builder.HasDiscriminator(m => m.Type).HasValue<ClassA>(...)
builder.HasDiscriminator(m => m.Type).HasValue<ClassB>(...)

it works well.

then, i want get all EntityType ( typeof classbase) and include the navigation A/B
ctx.Set<ClassBase>().include( ...)

i do not know how, and i tried

ctx.Set<ClassBase>()
    .OfType<ClassA>().Include(m=>m.NavigationA)
    .OfType<ClassB>().Include(m=>m.NavigationB)

but it's error

I need help ,thank you!

xiaoxin

@divega
Copy link
Contributor

divega commented Aug 15, 2016

@xiaoxin1983 currently there is no supported way to write a single query that would include related entities for multiple derived types in the hierachy.

Issue #3910 in the backlog represents an enhancement that could allow this.

In the meanwhile my recommendation is to use separate queries, e.g.:

var as = ctx.Set<ClassBase>()
    .OfType<ClassA>().Include(m=>m.NavigationA).ToList();

var bs = ctx.Set<ClassBase>()
    .OfType<ClassB>().Include(m=>m.NavigationB).ToList();

@divega
Copy link
Contributor

divega commented Aug 15, 2016

Closing as duplicate of #3910.

@divega divega closed this as completed Aug 15, 2016
@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

3 participants