private static EntityType FindParentTable( DbDatabaseMapping databaseMapping, EntityType fromTable, EntityTypeMapping entityTypeMapping, EntityType toTable, bool isMappingInheritedProperties, int configurationIndex, int configurationCount, out bool isSplitting) { EntityType entityType = (EntityType)null; isSplitting = false; if ((entityTypeMapping.UsesOtherTables(toTable) || configurationCount > 1) && configurationIndex != 0) { entityType = entityTypeMapping.GetPrimaryTable(); isSplitting = true; } if (entityType == null && fromTable != toTable && !isMappingInheritedProperties) { for (EdmType baseType = entityTypeMapping.EntityType.BaseType; baseType != null && entityType == null; baseType = baseType.BaseType) { EntityTypeMapping entityTypeMapping1 = databaseMapping.GetEntityTypeMappings((EntityType)baseType).FirstOrDefault <EntityTypeMapping>(); if (entityTypeMapping1 != null) { entityType = entityTypeMapping1.GetPrimaryTable(); } } } return(entityType); }
private static EntityType FindParentTable( DbDatabaseMapping databaseMapping, EntityType fromTable, EntityTypeMapping entityTypeMapping, EntityType toTable, bool isMappingInheritedProperties, int configurationIndex, int configurationCount, out bool isSplitting) { EntityType parentTable = null; isSplitting = false; // Check for entity splitting first, since splitting on a derived type in TPT/TPC will always have fromTable != toTable if (entityTypeMapping.UsesOtherTables(toTable) || configurationCount > 1) { if (configurationIndex != 0) { // Entity Splitting case parentTable = entityTypeMapping.GetPrimaryTable(); isSplitting = true; } } if (parentTable == null && fromTable != toTable && !isMappingInheritedProperties) { // TPT case var baseType = entityTypeMapping.EntityType.BaseType; while (baseType != null && parentTable == null) { // Traverse to first anscestor with a mapping var baseMapping = databaseMapping.GetEntityTypeMappings((EntityType)baseType).FirstOrDefault(); if (baseMapping != null) { parentTable = baseMapping.GetPrimaryTable(); } baseType = baseType.BaseType; } } return(parentTable); }