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]
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.
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.
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