How to map multiple records from a single SP with Dapper-dot-net

前端 未结 1 993
傲寒
傲寒 2021-01-02 03:34

I\'d like to use Dapper in a situation where the execution of a single stored procedure will return 50 multiple separate selects, none of the individual result sets will be

相关标签:
1条回答
  • 2021-01-02 04:05

    This one is from the home page, but there should be similar in the tests:

    var sql = @"...";
    using (var multi = connection.QueryMultiple(sql, new {id=selectedId}))
    {
       var customer = multi.Read<Customer>().Single();
       var orders = multi.Read<Order>().ToList();
       var returns = multi.Read<Return>().ToList();
       ...
    } 
    

    Arguments etc work as normal, and should map directly to defined parameter names if CommandType is specified.

    Each call to .Read<T>() relates to a successive results grid.

    0 讨论(0)
提交回复
热议问题