简体   繁体   中英

Entity Framework Core - Include Multiple Levels Not Returning All Data

I have a query to my EF core database which should return all the gear for each gear level for each hero.

I use the query below to get the data from the database:

    DbSet = context.Set<GuildMemberHero>();        

    var check = DbSet
        .Where(x => x.GuildMember.Id == guildMemberId)
        .Include(x => x.GuildMemberGearLevels).ThenInclude(y => y.GuildMemberGear)
        .Include(x => x.Hero).ThenInclude(x => x.GearLevels).ThenInclude(y => y.Gear)
        .ToList();

However, I am not getting all the data returned from the 'ThenInclude' statements but I am if i run a similar query in SQL itself.

Does the query to get all the items from EF remove duplicates as some of the data does have duplicate details?

I had the same issue and finally I discovered that Entity Framework uses your own implementation of Equals when mapping the data returned into classes.

Check if you have overwritten the Equals method in any of your entities and there are properties that are not being compared.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM