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 a returned scalar value in Dapper?
<p>To use a stored procedure and retrieve a returned scalar value, you need to use the <a href="https://www.learndapper.com/dapper-query/selecting-scalar-values">ExecuteScalar</a> method:</p> <pre><code class="language-sql">CREATE PROCEDURE MyStoredProcedure AS BEGIN SELECT 1 END </code></pre> <pre><code class="language-csharp">using (var connection = new SqlConnection("connectionString")) { var scalarValue = connection.ExecuteScalar<int>("MyStoredProcedure", commandType: CommandType.StoredProcedure); Console.WriteLine(scalarValue); } </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
?