How to map to a Dictionary object from database results using Dapper Dot Net?
If I have a simple query such as: string sql = "SELECT UniqueString, ID FROM Table"; and I want to map it to a dictionary object such as: Dictionary<string, int> myDictionary = new Dictionary<string, int>(); How would I do this with Dapper? I assume it is something like: myDictionary = conn.Query<string, int>(sql, new { }).ToDictionary(); But can't figure out the proper syntax. There's various ways already shown; personally I'd just use the non-generic api: var dict = conn.Query(sql, args).ToDictionary( row => (string)row.UniqueString, row => (int)row.Id); Tim Schmelter Works also without an