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

前端 未结 1 995
傲寒
傲寒 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().Single();
       var orders = multi.Read().ToList();
       var returns = multi.Read().ToList();
       ...
    } 
    

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

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

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