nerdexam
Microsoft

70-516 · Question #59

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that uses the EntityFramework. The application has an entity named Person. A Person instance named…

The correct answer is A. model.DeleteObject(person1). ObjectContext.DeleteObject Marks an object for deletion from the ObjectStateManager. The object is deleted in the data source when the SaveChanges method is called. ObjectContext.ExecuteStoreCommand Method executes an arbitrary command directly against the data source using the…

Manipulating and Validating Data

Question

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that uses the EntityFramework. The application has an entity named Person. A Person instance named person1 and an ObjectContext instance named model exist. You need to delete the person1 instance. Which code segment should you use?

Options

  • Amodel.DeleteObject(person1);
  • Bmodel.Detach(person1);
  • Cmodel.ExecuteStoreCommand("Delete",
  • Dmodel.ExecuteStoreCommand("Detach",

How the community answered

(32 responses)
  • A
    75% (24)
  • B
    16% (5)
  • C
    6% (2)
  • D
    3% (1)

Explanation

ObjectContext.DeleteObject Marks an object for deletion from the ObjectStateManager. The object is deleted in the data source when the SaveChanges method is called. ObjectContext.ExecuteStoreCommand Method executes an arbitrary command directly against the data source using the existing connection.

Topics

#Entity Framework#ObjectContext#DeleteObject#entity deletion

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice