Skip to content

DbParameters with same name in FromSql/SqlQueryRaw get incorrectly deduplicated #35196

@roji

Description

@roji

Test Multiple_occurrences_of_SqlQuery_with_db_parameter_adds_parameter_only_once has two SqlQueryRaw invocations with two different DbParameter instances, which have the same name:

var city = "Seattle";
var qqlQuery = context.Database.SqlQueryRaw<UnmappedCustomer>(
    NormalizeDelimitersInRawString(@"SELECT * FROM [Customers] WHERE [City] = {0}"),
    CreateDbParameter("city", city));

var query = qqlQuery.Intersect(qqlQuery);

The test ensures that only one parameter actually gets sent to the database, but this is wrong if there's some parameter facet that differs between the two (e.g. Size). Since there's (probably?) no reliable way to compare DbParameters across providers, and detecting this doesn't seem too important, we should probably just send two parameters instead. The same is true of FromSql.

/cc @ajcvickers

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions