相关疑难解决方法(0)

如何使用Dapper Dot Net从数据库结果映射到Dictionary对象?

如果我有一个简单的查询,例如:

string sql = "SELECT UniqueString, ID  FROM Table";
Run Code Online (Sandbox Code Playgroud)

我想将它映射到字典对象,例如:

Dictionary<string, int> myDictionary = new Dictionary<string, int>();      
Run Code Online (Sandbox Code Playgroud)

我怎么用Dapper这样做?

我假设它是这样的:

myDictionary = conn.Query<string, int>(sql, new {  }).ToDictionary();
Run Code Online (Sandbox Code Playgroud)

但无法弄清楚正确的语法.

c# asp.net dapper

55
推荐指数
6
解决办法
4万
查看次数

标签 统计

asp.net ×1

c# ×1

dapper ×1