ZZZ Code AI
Report Issues
Suggest Features
Login
Dapper Tools
Chat
Code Explain
Seed Data Generator
Sql Generator
Stored Procedure Generator
Entity to Table Converter
Table to Entity Converter
Sql Injection Detector
More Tools
How to use a stored procedure to retrieve multiple returned results in Dapper?
<p>To use a stored procedure and retrieve multiple returned results, you need to use the <a href="https://www.learndapper.com/dapper-query/selecting-multiple-results">QueryMultiple</a> method and read every results by either mapping it to an anoymous type or a strongly typed object:</p> <pre><code class="language-csharp">using (var connection = new SqlConnection("connectionString")) { connection.Open(); using (var results = connection.QueryMultiple("MyStoredProcedure", commandType: CommandType.StoredProcedure)) { // Anonymous Type var resultSet1 = results.Read().ToList(); // Strongly Typed Object var resultSet2 = results.Read<ResultType2>().ToList(); } } public class ResultType2 { public int ID { get; set; } public string Name { get; set; } } </code></pre>
Sponsored by
Dapper Plus
This field is required
A text with a minimum of 10 characters is required
Send
Legal & Licensing
Answer generated by AI may produce inaccurate information about code, people, facts, and more.
Advertising Break!
5
seconds left
Did you know...
That you can now sponsor this project on
GitHub
?