nerdexam
Microsoft

70-516 · Question #90

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application. You use the Entity Framework Designer to create the following Entity Data Model. You write a method…

The correct answer is C. partial void OnPostalCodeChanging(string value). Another area of extensibility is with the partial methods created on each entity type. There is a pair of partial methods called OnXxxChanging and OnXxxChanged for each property, in which Xxx is the name of the property. The OnXxxChanging method executes before the property has…

Manipulating and Validating Data

Question

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application. You use the Entity Framework Designer to create the following Entity Data Model. You write a method named ValidatePostalCode to validate the postal code for the application. You need to ensure that the ValidatePostalCode method is called before the PostalCode property set method is completed and before the underlying value has changed. Which code segment should you place in the entity’s partial class?

Options

  • Apartial void OnPostalCodeChanged(string value)
  • Bpublic string ValidatedPostalCode
  • Cpartial void OnPostalCodeChanging(string value)
  • Dpublic string ValidatedPostalCode

How the community answered

(45 responses)
  • A
    13% (6)
  • B
    9% (4)
  • C
    73% (33)
  • D
    4% (2)

Explanation

Another area of extensibility is with the partial methods created on each entity type. There is a pair of partial methods called OnXxxChanging and OnXxxChanged for each property, in which Xxx is the name of the property. The OnXxxChanging method executes before the property has changed, and the OnXxxChanged method executes after the property has changed. To implement any of the partial methods, create a partial class and add the appropriate partial method with implementation code. CHAPTER 6 ADO.NET Entity Framework Lesson 1: What Is the ADO.NET Entity Framework? Partial Classes and Methods(page 390) How to: Execute Business Logic During Scalar Property Changes

Topics

#Entity Framework#partial class#OnChanging event#property validation

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice