Created
October 20, 2017 02:37
-
-
Save thiagoloureiro/94f67c4acdc5edaf4c4a8ec1d9db6525 to your computer and use it in GitHub Desktop.
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
List<Customer> ret; | |
using (var db = new SqlConnection(connstring)) | |
{ | |
var sql = | |
"select C.[Id], C.[Name], C.[Email], C.[Phone], A.CustomerId, A.Street, " + | |
"A.City, A.Country, A.ZIPCode from customer C " + | |
"inner join[Address] A on A.CustomerId = C.Id"; | |
ret = db.Query<Customer, Address, Customer>(sql, (customer, address) => | |
{ | |
customer.Address = address; | |
return customer; | |
}, splitOn: "CustomerId").ToList(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment