Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Customer
- {
- public int CustomerId { get; set;}
- public int CustomerName { get; set; }
- }
- public class Order
- {
- public int OrderId { get; set; }
- public int CustomerId { get; set; } //BuyerCustomer
- public int CustomerSecondId { get; set; } //ReceiverCustomer
- public Customer BuyerCustomer { get; set; }
- public Customer ReceiverCustomer { get; set; }
- }
- SELECT a.*, b.*, c.* FROM dbo.PRODUCTS_ORDER a
- INNER JOIN dbo.CUSTOMER b ON a.CustomerId=b.CustomerId
- INNER JOIN dbo.CUSTOMER c ON a.ShippingCustomerId=b.CustomerId
- List<Order> order= null;
- order= (List<Order>)
- var con=connection.Query<Order, Customer, Customer, Order>(sql,
- (order, customer1,customer2) =>
- {
- order.BuyerCustomer = customer1;
- order.ReceiverCustomer = customer2;
- return order;
- }, splitOn: "CustomerId,CustomerSecondId ");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement