PrepAway - Latest Free Exam Questions & Answers

What are two possible ways to achieve this goal?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server 2008 database. You create classes by using LINQ to SQL based on the records shown in the exhibit. (Click the Exhibit button.) You need to create a LINQ query to retrieve a list of objects that contains the OrderID and CustomerID properties. You need to retrieve the total price amount of each Order record. What are two possible ways to achieve this goal (Each correct answer presents a complete solution. Choose two.)

PrepAway - Latest Free Exam Questions & Answers

A.
from details in dataContext.Order_Details
group details by details.OrderID into g join order in dataContext.Orders on g.Key equals order.OrderID
select new { OrderID = order.OrderID, CustomerID = order.CustomerID, TotalAmount = g.Sum(od => od.UnitPrice * od.Quantity) }

B.
dataContext.Order_Details.GroupJoin(dataContext.Orders, d => d.OrderID, o => o.OrderID, (dts, ord) => new { OrderID = dts.OrderID, CustomerID = dts.Order.CustomerID, TotalAmount = dts.UnitPrice * dts.Quantity } )

C.
from order in dataContext.Orders
group order by order.OrderID into g join details in dataContext.Order_Details on g.Key equals details.OrderID
select new { OrderID = details.OrderID, CustomerID = details.Order.CustomerID, TotalAmount = details.UnitPrice * details.Quantity }

D.
dataContext.Orders.GroupJoin(dataContext.Order_Details, o => o.OrderID, d => d.OrderID, (ord, dts) => new { OrderID = ord.OrderID, CustomerID = ord.CustomerID, TotalAmount = dts.Sum(od => od.UnitPrice * od.Quantity) } )


Leave a Reply