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

Multiple repeated records when using Include and ThenInclude #9553

Closed
fkhasib opened this issue Aug 24, 2017 · 1 comment
Closed

Multiple repeated records when using Include and ThenInclude #9553

fkhasib opened this issue Aug 24, 2017 · 1 comment

Comments

@fkhasib
Copy link

fkhasib commented Aug 24, 2017

This was suppose to be fixed by 2.0.0 but I still get this error, if I have an entity with Include and then include, I end up with multiple records for the same Entity Y

var q = dbTenantContext.Yes
                                        .Include(e => e.Y)
                                            .ThenInclude(e => e.YY)
                                                .ThenInclude(e => e.YYY)
                                                    .ThenInclude(e => e.YYYY)
                                        .Include(e => e.Y)
                                            .ThenInclude(e => e.YY)
                                                .ThenInclude(e => e.YYY)
                                                    .ThenInclude(e => e.YYYX)
                                                        .ThenInclude(e => e.YYYXX)
                                         .Include(e => e.Z)
                                            .ThenInclude(e => e.ZZ)
                                                .ThenInclude(e => e.ZZZ)
                                                    .ThenInclude(e => e.ZZZZ)
                                        .Include(e => e.Z)
                                            .ThenInclude(e => e.ZZ)
                                                .ThenInclude(e => e.ZZX)
                                                   .ThenInclude(e => e.ZZXX)
                                        .Where(e => e.IsDeleted != true)

I used to fix this in 1.1 by adding at the end of the query the following

.GroupBy(e => e.Id)
 .Select(e => e.First())

but now with 2.0.0 I am getting the following error if I add that group and select

Expression of type 'System.Object' cannot be used for parameter of type 'Microsoft.EntityFrameworkCore.Metadata.IEntityType'

Further technical details

EF Core version: 2.0
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: MS Windows 7
IDE: Visual Studio 2017

@smitpatel
Copy link
Contributor

duplicate of #9551

@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