You use Microsoft .NET Framework 4 to develop an application that uses LINQ to SQL. You create a
data model named AdvWorksDataContext, and you add the Product table to the data model. The
Product table contains a decimal column named ListPrice and a string column named Color. You
need to update the ListPrice column where the product color is Black or Red. Which code segment
should you use?
A.
 string[] colorList = new string[] {“Black”,”Red”}; 
AdvWorksDataContext dc = new AdvWorksDataContext(); 
var prod = from p in dc.Products 
where colorList.Contains(p.Color) 
select p; 
foreach (var product in prod) 
{ 
product.ListPrice = product.StandardCost * 1.5M; 
} 
dc.SubmitChanges();
B.
 AdvWorksDataContext dc = new AdvWorksDataContext( “& ” ); 
var prod = from p in dc.Products 
select p; 
var list = prod.ToList(); 
foreach (Product product in list) 
{ 
if (product.Color == “Black,Red”) 
{ 
product.ListPrice = product.StandardCost * 1.5M; 
}} 
dc.SubmitChanges();
C.
 AdvWorksDataContext dc = new AdvWorksDataContext( “& ” ); 
var prod = from p in dc.Products 
where p.Color == “Black,Red” 
select p; 
foreach (var product in prod) 
{ 
product.ListPrice = product.StandardCost * 1.5M; 
} 
dc.SubmitChanges();
D.
 AdvWorksDataContext dc = new AdvWorksDataContext( “& ” ); 
var prod = from p in dc.Products 
select p; 
var list = prod.ToList(); 
foreach (Product product in list) 
{ 
if ((product.Color == “Black”)&&(product.Color == “Red”)) 
{ 
product.ListPrice = product.StandardCost * 1.5M; 
}} 
dc.SubmitChanges();