Which code segment should you use?

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.

Each region contains a single vendor. Customers order parts from the vendor that is located in their
region. You need to ensure that each row in the Customer table references the appropriate row
from the Vendor table. Which code segment should you use?

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.

Each region contains a single vendor. Customers order parts from the vendor that is located in their
region. You need to ensure that each row in the Customer table references the appropriate row
from the Vendor table. Which code segment should you use?

A.
Dim dc As SalesDataContext = New SalesDataContext( “…” )
Dim query = From c In dc.Customers
Join v In dc.Vendors On c.Region Equals v.Region
Select New With {.Customer = c, -Vendor = v}
For Each u In query
u.Vendor.VendorlD = u.Customer.VendorlD
Next
dc.SubmitChanges()

B.
Dim dc As SalesDataContext – New SalesDataContext ( “…” )
Dim query = From v In dc.Vendors
Join c In dc.Customers On v.Region Equals c.Region
Select New With {.Vendor = v, -Customer = c> For Each u In query
u.Customer.VendorID = u.Vendor.VendorID
Next
dc.SubmitChanges()

C.
Dim dc As SalesDataContext = New SalesDataContext( “…” )
Dim query = From c In dc.Customers
Join v In dc.Vendors On c.VendorID Equals v.VendorID
Select New With {.Customer = c, -Vendor = v)
For Each u In query
u.Vendor.Region = u.Customer.Region
Next
dc.SubmitChanges()

D.
Dim dc As SalesDataContext – New SalesDataContext( “…”)
Dim query = From v In dc.Vendors

Join c In dc.Customers On v.VendorID Equals c.VendorID Select New With {.Vendor = v, .Customer =
c} For Each u In query
u.Customer.Region = u.Vendor.Region
Next
dc.SubmitChanges()



Leave a Reply 0

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