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 Shared Sub Insert()
02
03 Dim dc As NorthuindDataContext –
New NorthwindDataContext (“…”)
04 Dim neuCustomer As Customer = New Customer()
05 newCustomer.Firstname = “Todd”
06 newCustomer.Lastname = “Meadows”
07 newCustomer.Email = “[email protected]
08
09 dc.SubmitChanges()
10 End Sub
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?

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 Shared Sub Insert()
02
03 Dim dc As NorthuindDataContext –
New NorthwindDataContext (“…”)
04 Dim neuCustomer As Customer = New Customer()
05 newCustomer.Firstname = “Todd”
06 newCustomer.Lastname = “Meadows”
07 newCustomer.Email = “[email protected]
08
09 dc.SubmitChanges()
10 End Sub
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?

A.
Dim newProduct As Product = New Produce()
newProduct.ProductName = “Bike Tire”
Dim newOrder As Order = New Order()
newOrder.Product = newProduct
newCustomer.Orders.Add(newOrder)

B.
Dim newProduct As Product = New Product()
newProduct.ProductName = “Bike Tire”
Dim newOrder As Order = New Order()
newOrder.Product = newProduct

C.
Dim newOrder As Order = New Order()
newOrder.Product = (From p in dc.Products
Where p.ProductName = “Bike Tire”
Select p) .First ()

D.
Dim newOrder As Order = 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 0

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