public void GetComplexPropertyMappings_should_return_all_complex_property_mappings_for_type() { var databaseMapping = new DbDatabaseMapping() .Initialize(new EdmModel(DataSpace.CSpace), new EdmModel(DataSpace.SSpace)); var entitySet = new EntitySet { Name = "ES" }; var entitySetMapping = databaseMapping.AddEntitySetMapping(entitySet); var entityTypeMapping = new StorageEntityTypeMapping(null); entitySetMapping.AddTypeMapping(entityTypeMapping); var entityTypeMappingFragment = new StorageMappingFragment(entitySet, entityTypeMapping, false); entityTypeMapping.AddFragment(entityTypeMappingFragment); var complexType = new ComplexType("C"); var propertyMapping1 = new ColumnMappingBuilder( new EdmProperty("C"), new[] { EdmProperty.Complex("P1", complexType), EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)) }); var type = typeof(object); complexType.Annotations.SetClrType(type); entityTypeMappingFragment.AddColumnMapping(propertyMapping1); var propertyMapping2 = new ColumnMappingBuilder( new EdmProperty("C"), new List<EdmProperty> { EdmProperty.Complex("P3", complexType), EdmProperty.Primitive( "P2", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)), }); entityTypeMappingFragment.AddColumnMapping(propertyMapping2); Assert.Equal(2, databaseMapping.GetComplexPropertyMappings(typeof(object)).Count()); }
internal void Configure(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest) { DebugCheck.NotNull(databaseMapping); DebugCheck.NotNull(providerManifest); foreach (var structuralTypeConfiguration in databaseMapping.Model.GetComplexTypes() .Select(ct => ct.GetConfiguration()) .Cast<StructuralTypeConfiguration>() .Where(c => c != null)) { structuralTypeConfiguration.Configure( databaseMapping.GetComplexPropertyMappings(structuralTypeConfiguration.ClrType), providerManifest); } ConfigureEntityTypes(databaseMapping, providerManifest); RemoveRedundantColumnConditions(databaseMapping); RemoveRedundantTables(databaseMapping); ConfigureTables(databaseMapping.Database); ConfigureDefaultSchema(databaseMapping); }
internal void Configure(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest) { DebugCheck.NotNull(databaseMapping); DebugCheck.NotNull(providerManifest); foreach (var structuralTypeConfiguration in databaseMapping.Model.ComplexTypes .Select(ct => ct.GetConfiguration()) .Cast<StructuralTypeConfiguration>() .Where(c => c != null)) { structuralTypeConfiguration.ConfigurePropertyMappings( databaseMapping.GetComplexPropertyMappings(structuralTypeConfiguration.ClrType).ToList(), providerManifest); } ConfigureEntityTypes(databaseMapping, databaseMapping.Model.Container.EntitySets, providerManifest); RemoveRedundantColumnConditions(databaseMapping); RemoveRedundantTables(databaseMapping); ConfigureTables(databaseMapping.Database); ConfigureDefaultSchema(databaseMapping); UniquifyFunctionNames(databaseMapping); ConfigureFunctionParameters(databaseMapping); RemoveDuplicateTphColumns(databaseMapping); }