PrepAway - Latest Free Exam Questions & Answers

Which code segment should you insert at line 08?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application
that uses LINQ to SQL. The application contains the following model.

You write the following code. (Line numbers are included for reference only.)
01 static void Insect()
02 {
03 NorthwindDataContext dc = new NorthwindDataContext();
04 Customer newCustomer = new Customer();
05 newCustomer.Firstname = “Todd”;
06 newCustomer.Lastname = “Meadows”;
07 newCustomer.Email = “troeadows@contoso.com”; 08
09 dc.SubmitChanges();
10 {
A product named Bike Tire exists in the Products table. The new customer orders the Bike Tire
product. You need to ensure that the correct product is added to the order and that the order is
associated with the new customer. Which code segment should you insert at line 08?

PrepAway - Latest Free Exam Questions & Answers

A.
Order newOrder = new Order();
newOrder.Product = (from p in dc.Products
where p.ProductName == “Bike Tire”
select p) .First();

B.
Product newProduct = new Product();
newProduct.ProductName = “Bike Tire”; Order
newOrder = new Order();
newOrder.Product = newProduct;

C.
Product newProduct = new Product();
newProduct.ProductName = “Bike Tire”;
Order newOrder = new Order ();
newOrder.Product = newProduct;
newCustomer.Orders.Add(newOrder) ;

D.
Order newOrder = new Order();
newOrder.Product = (from p in dc.Products
where p.ProductName == “Bike Tire”
select p).First();
newCustomer.Orders.Add(newOrder) ;

Explanation:


Leave a Reply