You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application
that uses the Entity Framework. You create the following Entity Data Model.
You write the following code. (Line numbers are included for reference only.)
01 Using context As New Model1Container()
02 Dim cust As Customer = context.Customers.First()
03 cust.CompanyName = “Contoso”
04 Dim count As Integer = 0
05
06 End Using
The changes to the cust entity must be saved. If an exception is thrown, the application must retry
the save 3 times. You need to add a code segment to meet the requirements. Which code segment
should you insert at line 05?
A.
 While (count < 3) 
Try 
context.SaveChanges() 
Exit While 
Catch ex As Exception 
End Try 
count += 1 
End While
B.
 While (cust.EntityState = EntityState.Modified) 
Try 
context.SaveChanges() 
Catch ex As Exception 
count += 1 
If (count > 2 AndAlso context.Connection.State = 
ConnectionState.Broken) Then 
Throw New Exception() 
End If 
End Try 
End While
C.
 While (True) 
AddHandler context.SavingChanges, _ 
Function(o As System.Object, e As System.EventArgs) 
count += 1 
If count > 2 Then 
Throw New Exception() 
End If 
context.SaveChanges() 
End Function 
End While
D.
 While (context.ObjectStateManager.GetObjectStateEntry( _ 
cust).OriginalValues.IsDBNull(0)) 
count += 1 
If (count > 2) Then 
Exit While 
End If 
context.SaveChanges() 
End While
