Literal replacements causing DAP214
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the shown query with Dapper AOT enabled and the listed package versions. Trace how the Dapper AOT analyzer handles literal replacements and supplied parameters. Done means the example compiles without DAP214 and binds Admin correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100