Database Reference
In-Depth Information
Following is the output of the code in Listing 12-10:
Robin St.James
Phone: 817 555-5555
First Political Office: Dog Catcher
Second Political Office: Mayor
Third Political Office: State Senator
How It Works
The current release of Entity Framework does not support the XML data type. Given the importance of XML, it is likely
that some future version will provide full support. In this recipe, we created a new property, CandidateResume, which
exposes the candidate's resume as XML.
The code in Listing 12-10 demonstrates using the CandidateResume property in place of the Resume property.
For both the getter and setter, we wired in a handler for the Changed event on the XML. This handler keeps the Resume
property in sync with the CandidateResume property. Entity Framework will look at the Resume property when it comes
time to persist an instance of the Candidate entity. Only changes to the Resume property will be saved. We need to reflect
changes in the CandidateResume property to the Resume property for the database to stay in sync (via Entity Framework).
12-11. Applying Server-Generated Values to Properties
Problem
You have several columns in a table whose values are generated by the database. You want to have Entity Framework
set the corresponding entity properties after inserts and updates.
Solution
Suppose that you have a table like the one in Figure 12-14 .
Figure 12-14. The ParkingTicket table with the TicketId, CreateDate, PaidDate, and TimeStamp columns generated by
the database
 
Search WWH ::




Custom Search