Execute Multiple Stored Procedures with Dapper .NET

dapper sql-server-2008

Question

Does Dapper.NET support executing multiple Stored Procedures at once? I have several SPs each with different set of parameters. I want to send a single call to SQL Server to execute all the SPs. Each SP returns multiple records.

Thanks

Accepted Answer

Yes:

using(var multi = conn.QueryMultiple(
    @"exec foo @a, @b;
    exec bar @a, @c", args))
{
    var foos = multi.Read<Foo>().ToList();
    var bars = multi.Read<Bar>().ToList();
}

(code is from memory; apologies for any minor typos)




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why