-1

我认为 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.Nullable1,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 应该是一个简单有趣的东西。

4

1 回答 1

2

所以事实证明,我的解决方案中的一个项目具有 Dapper dll 的旧副本。即使我在我的项目中使用了最新版本的 Dapper(来自 NuGet),但在构建期间部署的 dll 肯定是旧的。

在更新所有项目引用以使用最新的 NuGet 包后,一切正常。

于 2014-02-19T04:37:41.570 回答