1

I have been replacing Entity Framework and LINQ queries with dapper.net as a means of data access with great success, I am seeing real improvements in speed. However when I try the same with a stored procedure, the result is the opposite, I get a Timeout expired error every time:

The stored procedure itself is unchanged so it's clearly not the issue, suffice to say it returns 2 result sets: data and a rowcount. It is used to populate a jquery datatable. This is the code used to call the proc:

public DapperQueryMultipleModel GetStockCatalogueDatatable_WIP(DatatableFilterModel model)
{
    DapperQueryMultipleModel returnModel = new DapperQueryMultipleModel();

    var p = new DynamicParameters();
    p.Add("@storeId", model.Store);
    // more params..
    p.Add("@TotalRowsCount", dbType: DbType.Int32, direction: ParameterDirection.Output);

    using (var connection = _context.Database.Connection)
    {
        using (var multi = connection.QueryMultiple("dbo.StockCatalogueDatatable", p, commandType: CommandType.StoredProcedure))
        {
           returnModel.TableData = multi.Read<dynamic>().ToList();
           returnModel.RowCount = multi.Read<int>().Single();
        }
     }
     return returnModel;
}

Am I doing something wrong?

2
  • Do you have more cases with QueryMultiple? Feb 19, 2016 at 23:47
  • Yes I use QueryMultiple a lot, but always with a query string, not a SP. I changed the dynamic return type to a class and that made a big improvement.
    – markpsmith
    Feb 21, 2016 at 16:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.