我看到了使用Dapper执行带有动态参数的存储过程并返回过程结果的示例.通常,这些示例使用.Execute,但其中一些使用.Query.我很难使用.Execute.我应该在上述情况下使用哪个 - 查询或执行AND在哪种情况下我会使用它们?
这是Dapper示例中的代码切割:
var p = new DynamicParameters();
p.Add("@a", 11);
p.Add("@b", dbType: DbType.Int32, direction: ParameterDirection.Output);
p.Add("@c", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue);
cnn.Execute("spMagicProc", p, commandType: commandType.StoredProcedure);
int b = p.Get("@b");
int c = p.Get("@c");
Run Code Online (Sandbox Code Playgroud)
任何人:在上面提供的示例代码中,我收到错误,"无法解析.Execute" - 指的是cnn.Execute.我查看连接对象,没有Execute的方法.小巧玲珑显然效果很好,所以我做错了什么?