-
-
Notifications
You must be signed in to change notification settings - Fork 30
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