This file contains hidden or 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
| public ConnectionFactory GetConnectionFactory() | |
| { | |
| var connectionFactory = new ConnectionFactory | |
| { | |
| HostName = "localhost", | |
| UserName = "guest", | |
| Password = "guest" | |
| }; | |
| return connectionFactory; | |
| } |
This file contains hidden or 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) => | |
| { |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| public class Address | |
| { | |
| public int Id { get; set; } | |
| public string Street { get; set; } | |
| public string City { get; set; } | |
| public string Country { get; set; } |
This file contains hidden or 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
| public class Customer | |
| { | |
| public int Id { get; set; } | |
| public string Name { get; set; } | |
| public string Email { get; set; } | |
| public string Phone { get; set; } |
NewerOlder