Return your query as dynamic
objects.
var query = connection.Query<dynamic>(
"Get_Something", commandType: CommandType.StoredProcedure, param: parameters);
Then, map your DTO's like this:
var results = new List<MyDto>();
foreach(item in query)
{
var dictionary = new RouteValueDictionary(item).ToDictionary(x => x.Key, y => y.Value);
var dto = new MyDto
{
Id = dictionary["Id"];
Code = dictionary["Code"];
}
dictionary.Remove("Id");
dictionary.Remove("Code");
dto.AdditionalColumns = dictionary;
results.Add(dto)
}
Reference
RouteValueDictionary Class
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…