Which LINQ query should you use?

You are creating an ASP.NET application by using the .NET Framework 3.5.

You use LINQ to SQL to query a Microsoft SQL Server 2008 database. You need to create a LINQ query to retrieve information on order and order details.

You need to ensure that the LINQ query executes the following SQL statement:

SELECT Order.OrderID

, Order.Description

, OrderDetails.UnitPrice

FROM Order JOIN OrderDetails

ON Order.OrderID = OrderDetails.OrderID

Which LINQ query should you use?

You are creating an ASP.NET application by using the .NET Framework 3.5.

You use LINQ to SQL to query a Microsoft SQL Server 2008 database. You need to create a LINQ query to retrieve information on order and order details.

You need to ensure that the LINQ query executes the following SQL statement:

SELECT Order.OrderID

, Order.Description

, OrderDetails.UnitPrice

FROM Order JOIN OrderDetails

ON Order.OrderID = OrderDetails.OrderID

Which LINQ query should you use?

A.
from order in db.Orders
join details in db.OrderDetails on
order.OrderID equals details.OrderID
select new {
order.OrderID, order.Description,
details.UnitPrice
};

B.
from order in db.Order
join details in db.OrderDetails on
order.OrderID equals details.OrderID into grp
from ord in grp.DefaultIfEmpty ()
select n ew {
or der.OrderID ,
order.Description ,
or d.UnitPrice )
};

C.
from order in db.Order
join details in db.OrderDetails on
order.OrderID equals details.OrderID into grp
select n ew {
or der.OrderID ,
order.Description ,
grp.First ().
UnitPrice
};

D.
from order in db.Orders
join details in db.OrderDetails on
order.OrderID equals details.OrderID
into grp let price = grp.DefaultIfEmpty().First()
select new {
order.OrderID,
order.Description,
price.UnitPrice
};



Leave a Reply 0

Your email address will not be published. Required fields are marked *