Looking for dapper Answers? Try Ask4KnowledgeBase
Looking for dapper Keywords? Try Ask4Keywords

Dapper.NET Query with Dynamic Parameters


var color = "Black";
var age = 4;

var query = "Select * from Cats where Color = :Color and Age > :Age";
var dynamicParameters = new DynamicParameters();
dynamicParameters.Add("Color", color);
dynamicParameters.Add("Age", age);

using (var connection = new SqlConnection(/* Your Connection String Here */))
    IEnumerable<dynamic> results = connection.Query(query, dynamicParameters);