In short, I am trying to take XML data and store it in a table. The structure giving me problems currently looks like so:
<Event>
<PhaseOne>...</PhaseOne>
<PhaseTwo>...</PhaseTwo>
<PhaseThree>...</PhaseThree>
<EventID>12345</EventID>
<EventDate>09/09/09</EventDate>
</Event>
The end result from this is 3 rows in my Event table (one for each <Phase>). Each row not only requires the data inside the respective <Phase> element, it also requires parent level values such as <EventID>.
I have the XSD.exe generated classes to deserialize the XML into but I’m at a loss at how to configure my EF Code First Mappings to generate the correct results.
I thought I would simply map each <Phase> class to the same table but then I’m not sure how I would map the parent level values (<EventID>) to columns in that row.
Unfortunately I cannot change the XML or the table schemas.
My solution
I added copies of the
EventIDandEventDatemembers to eachPhaseclass and then populated them manually post-deserialization.