/**
* @access private
*
* Maps the supplied entity data to result rows and maps any relationship changes.
*
* @param Object\UnitOfWork $UnitOfWork
* @param Relational\Transaction $Transaction
* @param IEntityRelationalMap $EntityRelationalMap
* @param Object\EntityData $EntityDataArray
* @return Relational\ResultRows[]
*/
private function MapEntityDataToTransaction(Object\UnitOfWork $UnitOfWork, Relational\Transaction $Transaction, IEntityRelationalMap $EntityRelationalMap, array $EntityDataArray)
{
$DataPropertyColumnMappings = $EntityRelationalMap->GetDataPropertyColumnMappings();
$EntityPropertyToOneRelationMappings = $EntityRelationalMap->GetEntityPropertyToOneRelationMappings();
$CollectionPropertyToManyRelationMappings = $EntityRelationalMap->GetCollectionPropertyToManyRelationMappings();
$ResultRowArray = [];
foreach ($EntityDataArray as $Key => $EntityData) {
$ResultRowArray[$Key] = $EntityRelationalMap->ResultRow();
}
foreach ($DataPropertyColumnMappings as $DataPropertyColumnMapping) {
$DataPropertyColumnMapping->Persist($EntityDataArray, $ResultRowArray);
}
foreach ($EntityDataArray as $Key => $EntityData) {
$ResultRow = $ResultRowArray[$Key];
foreach ($EntityPropertyToOneRelationMappings as $EntityPropertyToOneRelationMapping) {
$RelationshipChange = $EntityData[$EntityPropertyToOneRelationMapping->GetProperty()];
$MappedRelationshipChange = $this->MapRelationshipChanges($UnitOfWork, $Transaction, $EntityRelationalMap, [$RelationshipChange])[0];
$EntityPropertyToOneRelationMapping->Persist($Transaction, $ResultRow, $MappedRelationshipChange);
}
foreach ($CollectionPropertyToManyRelationMappings as $CollectionPropertyToManyRelationMapping) {
$RelationshipChanges = $EntityData[$CollectionPropertyToManyRelationMapping->GetProperty()];
$MappedRelationshipChanges = $this->MapRelationshipChanges($UnitOfWork, $Transaction, $EntityRelationalMap, $RelationshipChanges);
$CollectionPropertyToManyRelationMapping->Persist($Transaction, $ResultRow, $MappedRelationshipChanges);
}
}
return $ResultRowArray;
}