Skip to content

Fix query filter parameter naming for primary constructors#38135

Closed
aw0lid wants to merge 1 commit intodotnet:mainfrom
aw0lid:fix/query-filter-parameter-naming
Closed

Fix query filter parameter naming for primary constructors#38135
aw0lid wants to merge 1 commit intodotnet:mainfrom
aw0lid:fix/query-filter-parameter-naming

Conversation

@aw0lid
Copy link
Copy Markdown

@aw0lid aw0lid commented Apr 18, 2026

Description

This PR fixes a regression introduced in 10.0.6 where queries using HasQueryFilter fail when the filter references a primary constructor parameter.

Root Cause

When a query filter captures a primary constructor parameter, the C# compiler generates a backing field with a name like <variable>P. The ExpressionTreeFuncletizer was using the raw Member.Name for the parameter name without sanitization, resulting in invalid SQL parameter names (e.g., @ef_filter__<tenantUuid>P) which causes a SqlException.

Fix

Applied SanitizeCompilerGeneratedName to the member name in the _generateContextAccessors block within ExpressionTreeFuncletizer.cs. This ensures that angle brackets and other compiler-generated characters are stripped before the SQL parameter name is constructed.

Fixes #38132

@aw0lid aw0lid requested a review from a team as a code owner April 18, 2026 00:09
@roji
Copy link
Copy Markdown
Member

roji commented Apr 18, 2026

Thanks, but I submitted #38136 for 10.0.7 with an extra safety check and appcontext switches.

@roji roji closed this Apr 18, 2026
@aw0lid aw0lid deleted the fix/query-filter-parameter-naming branch April 18, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query filters with primary constructor parameters fail in 10.0.6

2 participants