-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Open
Labels
Description
Describe the bug
When using Literal replacement ({=XXX}) in a SQL query, Dapper AOT emits the following error:
Error DAP214 : Variable @XXX is not declared and no corresponding parameter exists (https://aot.dapperlib.dev/rules/DAP214)
This happens even though the parameter is correctly supplied in the parameters object.
If I change the query to use @XXX instead of {=XXX}, it works correctly.
To Reproduce
var result = await db.QueryAsync(
"select Id, Name from Users where UserTypeId = {=Admin}",
new { Admin = 123 });- Compile with Dapper AOT enabled.
- Observe the error
DAP214.
Expected behavior
Dapper should recognize Admin as a supplied parameter and generate code that binds it correctly when used with Literal replacement.
Actual behavior
Dapper reports DAP214 and refuses to compile, incorrectly stating that the parameter does not exist.
Additional context
TargetFramework = net9.0
Dapper Version = 2.1.66
Dapper.AOT Version = 1.0.48
Microsoft.Data.SqlClient Version = 6.1.1