nerdexam
Microsoft

70-516 · Question #145

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that uses the Entity Framework. You create the following Entity Data Model. You add the following code…

The correct answer is B. while(cust.EntityState == EntityState.Modified). See the full explanation below for the reasoning.

Question

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that uses the Entity Framework. You create the following Entity Data Model. You add the following code fragment:

using(var context = new AdventureWorksLTEntities()) { Customer cust = context.Customers.First(); cust.CompanyName = "Contoso"; int count = 0; } The changes to the cust entity must be saved. If an exception is thrown, the application will attempt to save up to 3 times. If not, an exception is thrown. Which code segment should you use?

Options

  • Awhile(count++ < 3)
  • Bwhile(cust.EntityState == EntityState.Modified)
  • Cwhile(true)
  • Dwhile(context.ObjextStateManager.GetObjectStateEntry(cust).

How the community answered

(47 responses)
  • A
    4% (2)
  • B
    74% (35)
  • C
    13% (6)
  • D
    9% (4)

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice