mesutd0nmez
7/17/2018 - 11:53 AM

Lambda Join Tables

var list = dc.Orders.
                Join(dc.Order_Details,
                o => o.OrderID, od => od.OrderID,
                (o, od) => new
                {
                    OrderID = o.OrderID,
                    OrderDate = o.OrderDate,
                    ShipName = o.ShipName,
                    Quantity = od.Quantity,
                    UnitPrice = od.UnitPrice,
                    ProductID = od.ProductID
                }).Join(dc.Products,
                        a => a.ProductID, p => p.ProductID,
                        (a, p) => new
                        {
                            OrderID = a.OrderID,
                            OrderDate = a.OrderDate,
                            ShipName = a.ShipName,
                            Quantity = a.Quantity,
                            UnitPrice = a.UnitPrice,
                            ProductName = p.ProductName
                        });