Introduction:
Here I will explain how to get multiple results or records from stored procedure using dapper in c#, vb.net or access multiple results or objects from stored procedure in dapper using querymultiple method in c#, vb.net.
Description:
In previous articles I explained start or stop IIS service in c#, vb.net, get values from ienumerable list in c#, vb.net, jQuery upload images without postback in asp.net, wcf tutorial for beginners with example in asp.net and many articles relating to AngularJS, jQuery, asp.net, c# and vb.net. Now I will explain how to get multiple results or records from stored procedure using dapper in c#, vb.net.
In previous articles I explained start or stop IIS service in c#, vb.net, get values from ienumerable list in c#, vb.net, jQuery upload images without postback in asp.net, wcf tutorial for beginners with example in asp.net and many articles relating to AngularJS, jQuery, asp.net, c# and vb.net. Now I will explain how to get multiple results or records from stored procedure using dapper in c#, vb.net.
To get multiple results from stored
procedure using dapper we need to use querymultiple
method that would be like as shown
C#
Code
|
VB.NET
Code
Using conn As IDbConnection
= New SqlConnection(connectionString)
Dim results As IEnumerable(Of
Dynamic) = conn.Query(sql:=storedProcedureName, param:=parameters,
commandType:=CommandType.StoredProcedure)
Dim reader =
conn.QueryMultiple(storedProcedureName, parameters, commandType:=CommandType.StoredProcedure)
Dim userdetails =
reader.Read(Of userdetails)().ToList()
Dim salarydetails =
reader.Read(Of salraydetails)().ToList()
End Using
Public Class userdetails
Public userid As Integer
Public username As String
End Class
Public Class salraydetails
Public salary As Integer
Public empid As Integer
End Class
|
I hope it helps you to get multiple results from stored
procedure using dapper…….Happy Coding….
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
5 comments :
This post is not as like your previous post
First time i did not understand any thing
Please describe in detail with db connectivity and all
And please post its output ,too
Thank you
if you know about dapper ORM then you will understand this post....
Hi suresh..
I have a question on it. In my scenario, i am getting about 5 result sets..If any of the result set returns null values.. then it throws an error. Please suggest me to proceed. Thanks in advance.
thanks
Note: Only a member of this blog may post a comment.