我认为 DapperExtensions 有一个非常简单的用例:
using (IDbConnection connection = Database.CreateConnection())
{
var model = connection.GetList<MyModelPoco>().ToList();
}
但是,抛出异常:
找不到方法:'System.Collections.Generic.IEnumerable 1<System.__Canon> Dapper.SqlMapper.Query(System.Data.IDbConnection, System.String, System.Object, System.Data.IDbTransaction, Boolean, System.Nullable
1,System.Nullable`1)'。
我将 NuGet 用于 Dapper (v1.13) 和 DapperExtensions (v1.4.3)。
任何想法为什么这不起作用?我补充说:
using Dapper;
不过,这并不影响结果。(Resharper 还抱怨说 using 指令是不必要的。)
当我直接使用 Dapper 时,它运行良好(尽管我注意到我使用它的方式与 DapperExtensions 不同):
using (IDbConnection connection = Database.CreateConnection())
{
var recordsets = connection.QueryMultiple("stored_procedure_name", new {parameterValue}, commandType:CommandType.StoredProcedure);
var model1 = recordsets.Read<Model1Poco>().SingleOrDefault();
if (model1 == null) return null;
model1.Model2Collection = recordsets.Read<Model2Poco>().ToList();
return model1;
}
我做了一些“谷歌搜索”,似乎共识是 DapperExtensions 应该是一个简单有趣的东西。