Yes:
var dbArgs = new DynamicParameters();
foreach(var pair in args) dbArgs.Add(pair.Key, pair.Value);
Then pass dbArgs
in place of args
:
var stuff = connection.Query<ExtractionRecord>(query, dbArgs);
Alternatively, you can write your own class that implements IDynamicParameters
.
Note that if you are starting from an object (the usual approach with dapper), you can also use this template with DynamicParameters
as a starting point:
var dbArgs = new DynamicParameters(templateObject);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…