示例#1
0
        private static void ConfigureUnconfiguredDerivedTypes(
            DbDatabaseMapping databaseMapping,
            ICollection <EntitySet> entitySets,
            DbProviderManifest providerManifest,
            EntityType entityType,
            IList <EntityTypeConfiguration> sortedEntityConfigurations)
        {
            var derivedTypes = databaseMapping.Model.GetDerivedTypes(entityType).ToList();

            while (derivedTypes.Count > 0)
            {
                var currentType = derivedTypes[0];
                derivedTypes.RemoveAt(0);

                // Configure the derived type if it is not abstract and is not otherwise configured
                // if the type is not configured, then also run through that type's derived types
                if (!currentType.Abstract &&
                    sortedEntityConfigurations.All(etc => etc.ClrType != currentType.GetClrType()))
                {
                    // run through mapping configuration to make sure property mappings point to where the base type is now mapping them
                    EntityTypeConfiguration.ConfigureUnconfiguredType(databaseMapping, entitySets, providerManifest, currentType, new Dictionary <string, object>());
                    derivedTypes.AddRange(databaseMapping.Model.GetDerivedTypes(currentType));
                }
            }
        }
示例#2
0
        private static void ConfigureUnconfiguredDerivedTypes(
            DbDatabaseMapping databaseMapping,
            ICollection <EntitySet> entitySets,
            DbProviderManifest providerManifest,
            EntityType entityType,
            IList <EntityTypeConfiguration> sortedEntityConfigurations)
        {
            List <EntityType> list = databaseMapping.Model.GetDerivedTypes(entityType).ToList <EntityType>();

            while (list.Count > 0)
            {
                EntityType currentType = list[0];
                list.RemoveAt(0);
                if (!currentType.Abstract && sortedEntityConfigurations.All <EntityTypeConfiguration>((Func <EntityTypeConfiguration, bool>)(etc => etc.ClrType != EntityTypeExtensions.GetClrType(currentType))))
                {
                    EntityTypeConfiguration.ConfigureUnconfiguredType(databaseMapping, entitySets, providerManifest, currentType, (IDictionary <string, object>) new Dictionary <string, object>());
                    list.AddRange(databaseMapping.Model.GetDerivedTypes(currentType));
                }
            }
        }