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

WhereBulkContains returns duplicate rows from the DB #591

Open
SClifford1 opened this issue Jun 19, 2024 · 1 comment
Open

WhereBulkContains returns duplicate rows from the DB #591

SClifford1 opened this issue Jun 19, 2024 · 1 comment
Assignees

Comments

@SClifford1
Copy link

SClifford1 commented Jun 19, 2024

Description

WhereBulkContains does not behave as I would have expected when filtering with a list containing duplicate entries. I expected filtered rows to appear at most once in the results but instead, I see rows duplicated.

This query returns a list of size 4, with Groups with ID 1 and 2 included twice. Id is the primary key of the groups table.

var targetGroups1 = await this.targetRepository.Set<Group>()
	.WhereBulkContains(( new List<int>() {1,1,2,2 } ), g => g.Id)
	.ToListAsync();

I would have expected the same behaviour as using a Contains with EF. This query returns a list of size 2, with Groups 1/2 included once.

var targetGroups2 = await this.targetRepository.Set<Group>()
	.Where(g => ( new List<int>() {1,1,2,2 } ).Contains(g.Id))
	.ToListAsync();

I can obviously work around this by providing a distinct list of Ids above but it would be good if this could be fixed all the same.

Further technical details

  • EF version: [EF Core v7.0.13]
  • EF Extensions version: [EFE Core v7.100.0.5]
  • Database Server version: [Azure SQL Database V12]
  • Database Provider version (NuGet): [Microsoft.Data.SqlClient v5.1.1]
@JonathanMagnan JonathanMagnan self-assigned this Jun 20, 2024
@JonathanMagnan
Copy link
Member

Hello @SClifford1 ,

Thank you for reporting. We will look into it.

Best Regards,

Jon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants