Created
May 29, 2019 04:31
-
-
Save mikependon/aff730f3db5416961e4776afd24d9646 to your computer and use it in GitHub Desktop.
IDbConnection (ExecuteQueryMultiple with StoredProcedure)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var connection = new SqlConnection(connectionString)) | |
{ | |
// Call the method by passing multiple statements | |
var extractor = connection.ExecuteQueryMultiple("SELECT * FROM [dbo].[Customer] WHERE Id = @CustomerId; " + | |
"EXEC [dbo].[sp_get_customer_orders] @CustomerId; " + | |
"SELECT GETUTCDATE() AS RetrievedDateTimeUtc;", | |
new { CustomerId = 10045 }); | |
// Extract the results | |
var customer = extractor.Extract<Customer>().FirstOrDefault(); | |
var orders = extractor.Extract<Order>().ToList(); | |
var retriveDateTime = extractor.Scalar<DateTime>(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment