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.
SalesDataContext dc = new SalesDataContext( “…” );
var query = from v in dc.Vendors
join c in dc.Customers on v.VendorlD equals c.VendorID
select new { Vendor = v, Customer= c };
foreach (var u in query)
{
u.Customer.Region = u.Vendor.Region;
}
dc.SubmitChanges();
B.
SalesDataContext dc = new SalesDataContext( “…” );
var query = from c in dc.Customers
join v in dc.Vendors on c.VendorlD equals v.VendorID
select new { Customer = c. Vendor = v };
foreach (var u in query)
{
u.Vendor.Region = u.Customer.Region;
dc.SubmitChanges();
C.
SalesDataContext dc = new SalesDataContext ( “…” ) ;
var query = from v in dc.Vendors
join c in dc.Customers on v.Region equals c.Region
select new { Vendor =v, Customer = c };
foreach (var u in query)
{
u.Customer.VendorlD = u.Vendor.VendorlD;
}
dc.SubmitChanges();
D.
SalesDataContext dc = new SalesDataContext ( “…” ) ;
var query = from c in dc.Customers
join v in dc.Vendors on c.Region equals v.Region
select new { Customer = c. Vendor = v };
foreach (var u in query)
{
u.Vendor.VendorlD = u.Customer.VendorID;
}
dc.SubmitChanges();