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

Object materialization duplicated when using IncludeMany #654

Open
enrico-padovani opened this issue Feb 27, 2022 · 3 comments
Open

Object materialization duplicated when using IncludeMany #654

enrico-padovani opened this issue Feb 27, 2022 · 3 comments

Comments

@enrico-padovani
Copy link

enrico-padovani commented Feb 27, 2022

Hi,

I'm facing an issue where using IncludeMany.

When there are more childrens for the main entity, the query composed repeats the main entity Id.

This causes the object with the same repeated id to be materialized multiple times.

If I order the main entity by the id column, the problem is fixed but this is not convenient because we need to have another order by after the object materialization.

NPoco Version 5.3.2
.NET 6

@enrico-padovani
Copy link
Author

I found this old issue #506 that seems to be the same problem.

Any advice how to solve it?

@schotime
Copy link
Owner

This would have to be fundamentally changed so that it used a Dictionary instead of an optimized list. Definitely a major version thing.

@enrico-padovani
Copy link
Author

enrico-padovani commented May 1, 2022

I don't know much about NPoco internals, but could it be possible to use the defined primary key over the entity in order to check if the object has already been added to the list?

If no PK is defined fall back to object equality.

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