to your account
public int C1Id { get; set; }
public int C2Id { get; set; }
public virtual C C1 { get; set; }
public virtual C C2 { get; set; }
public class C
public int Id { get; set; }
BTW because these are reference (and not collection) properties, you can do this for short. ThenInclude only becomes mandatory when you want to include after a collection navigation property.
Company company = _context.Companies
.Include(c => c.Users)
.Include(c => c.Projects)
.ThenInclude(p => p.Specifications)
.ThenInclude(spec => spec.Info)
.ThenInclude(info => info.Details)
.Include(c => c.Projects)
.ThenInclude(p => p.Specifications)
.ThenInclude(spec => spec.Files)
.Where(t => t.CompanyId.Equals(companyId))
.FirstOrDefault();
The details
objects are missing in the query and not returned. Any idea?
ashahabov, itsmecurtis, johncrisostomo, dochal, AETSTUDIO, andjiev, EmanuelDavid, MisterJimson, divieirasilva, nttai9319, and 12 more reacted with thumbs up emoji
sergej-kodit reacted with heart emoji
All reactions
it would be great this substitute syntax instead of repeat one thing consecutively
return _cart .Include(x => x.GameItems) .ThenInclude(x=>x.Game) .ThenInclude(x=>new{x.League,x.Host,x.Guest}) .AsQueryable();
instead of
return _cart
.Include(x => x.GameItems)
.ThenInclude(x=>x.Game)
.ThenInclude(x=>x.League)
.Include(x => x.GameItems)
.ThenInclude(x=>x.Game)
.ThenInclude(x=>x.Host)
.Include(x => x.GameItems)
.ThenInclude(x=>x.Game)
.ThenInclude(x=>x.Guest)
.AsQueryable();
it's more comprehensible and shorter and easier
After doing this how exactly would I get a where condition from either C1 or C2? seems not to work when I try it with my repository pattern and EF6. Any leads here?
db.A .Include(a => a.B.C1) .Include(a => a.B.C2)
include theinclude both works fine... b ut only problem is intellisense not identifying or showing the methods just type and then proceed all works fine ...
var res = await _context.Diseases.Include(x => x.Disease2Symptom) .ThenInclude(z => z.Symptom).ToListAsync();
include theinclude both works fine... b ut only problem is intellisense not identifying or showing the methods just type and then proceed all works fine ...
var res = await _context.Diseases.Include(x => x.Disease2Symptom) .ThenInclude(z => z.Symptom).ToListAsync();
Thanks. It took me a long time to realize that what I was trying to do was perfectly valid but that it just wasn't showing in intellisense. I should have just typed it anyway.
Example:
intellisense works fine here:
from q in db.SecurityGroupPermissions
.Include(x => x.SecurityAction)
intellisense does not work on the last item here. A list will pop up but it won't have SecurityAction in the popup:
from q in db.SecurityGroups
.Include(x => x.SecurityGroupPermissions)
.ThenInclude(x => x.SecurityAction)
Once I ignored intellisense and typed it out anyway then it built and ran correctly.
JLance14, AdamDiament, jeangatto, ScholliYT, jmoralesv, m-ermolaev, tedchirvasiu, miltonhowe, suadev, CleytonGoncalves, and 64 more reacted with thumbs up emoji
aleksa-kuzman, annerajb, and arunthomasarun reacted with confused emoji
a-patel, AdamDiament, jmoralesv, jupjohn, m-ermolaev, DanielFalzon, K20shores, Farami, AlexVPerl, TheEskhaton, and 17 more reacted with eyes emoji
All reactions
gergo123, rafaelgianine, ddegasperi, BassFaceIV, Uraharadono, GorganGabi, sorensenmarius, Elip-tdlr, andDaviD, fernandobracaroto, and 24 more reacted with thumbs up emoji
arunthomasarun, ohnv, martijnhoekstra, kobynz, and rgwebb reacted with confused emoji
arunthomasarun, rgwebb, and Ignisz reacted with eyes emoji
All reactions
@Uraharadono only 22 lines of code? I just wrote one with 45 lines of Include() and ThenInclude() chaining. Admittedly, each on a new line for readability.
I thought that there surely must be a better way by now but alas!
Any news whether "Include.ThenInclude.AlsoInclude" syntax or similar will be implemented for a more elegant solution to this problem?
Why is this closed without any follow up?