DapperLib / DapperLib/DapperAOT
Support for dynamic SQL with variable parameters in AOT mode
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 472
- Forks
- 43
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 18
Description
I have a very simple case, but I’m not sure how to implement it. I’ve prepared the project for AOT, and interceptors with hardcoded SQL (e.g., QueryAsync<T>("some sql")) work correctly and generate the expected code.
However, I also have dynamically generated SQL, where I use a similar operation. The number of parameters in the WHERE clause changes along with the generated query. The output/result type (<T>) remains the same, but the query text and the number of bound parameters vary with each call.
Is it possible to use Dapper.AOT in this scenario, or do I have to abandon Dapper entirely in this case - because it cannot be used with AOT when the number of query parameters changes dynamically? Should I fall back to using ADO.NET in such situations (as AOT is the goal)?
The sample is below:
var dynParams = query.GetDynamicParameters();
var command = new CommandDefinition(
commandText: query.Query,
parameters: dynParams,
commandType: CommandType.Text
);
var metadatas = await connection.QueryAsync<FileInfoDao>(command);
When I run the code I receive an error like below (.Net 9):
System.PlatformNotSupportedException
HResult=0x80131539
Message=Dynamic code generation is not supported on this platform.
Source=System.Private.CoreLib
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
The relevant entry point shown is connection.QueryAsync(command), using CommandDefinition and dynamic parameters. Reproduce it under .NET 9 AOT and compare it with the hardcoded QueryAsync case. Done means establishing whether this usage is supported and documenting the required approach or limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100