nerdexam
Microsoft

70-516 · Question #208

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database. The application uses the ADO.NET Entity…

The correct answer is A. Contact customer = context.Contact.Where("it.ContactID = @customerId". See the full explanation below for the reasoning.

Question

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database. The application uses the ADO.NET Entity Framework to model entities. The database includes objects based on the exhibit (click the Exhibit button). The application includes the following code segment. (Line numbers are included for reference only.) 01 using(AdventureWorksEntities context = new AdventureWorksEntities()) 02 { 03 ... 04 foreach (SalesOrderHeader order in customer.SalesOrderHeader) 05 { 06 Console.WriteLine(String.Format("Order: {0} ", order.SalesOrderNumber)); 07 foreach (SalesOrderDetail item in order.SalesOrderDetail) 08 { 09 Console.WriteLine(String.Format("Quantity: {0} ", item.Quantity)); 10 Console.WriteLine(String.Format("Product: {0} ", item.Product.Name)); 11 } 12 } 13 } You want to list all the orders for a specific customer. You need to ensure that the list contains following fields:

  • Order number
  • Quantity of products
  • Product name

Which code segment should you insert in line 03?

Options

  • AContact customer = context.Contact.Where("it.ContactID = @customerId",
  • BContact customer = context.Contact.Where("it.ContactID = @customerId",
  • CContact customer = (from contact in context.Contact.
  • DContact customer = (from contact in context.Contact.

How the community answered

(28 responses)
  • A
    82% (23)
  • B
    4% (1)
  • C
    11% (3)
  • D
    4% (1)

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice