private void ConfigureAssociations(EdmEntityType entityType, EdmModel model) { Contract.Requires(entityType != null); Contract.Requires(model != null); foreach (var configuration in _navigationPropertyConfigurations) { var propertyInfo = configuration.Key; var navigationPropertyConfiguration = configuration.Value; var navigationProperty = entityType.GetNavigationProperty(propertyInfo); if (navigationProperty == null) { throw Error.NavigationPropertyNotFound(propertyInfo.Name, entityType.Name); } navigationPropertyConfiguration.Configure(navigationProperty, model, this); } }
private void ConfigureAssociationMappings(DbDatabaseMapping databaseMapping, EdmEntityType entityType) { Contract.Requires(databaseMapping != null); foreach (var configuration in _navigationPropertyConfigurations) { var propertyInfo = configuration.Key; var navigationPropertyConfiguration = configuration.Value; var navigationProperty = entityType.GetNavigationProperty(propertyInfo); if (navigationProperty == null) { throw Error.NavigationPropertyNotFound(propertyInfo.Name, entityType.Name); } var associationSetMapping = databaseMapping.GetAssociationSetMappings() .SingleOrDefault(asm => asm.AssociationSet.ElementType == navigationProperty.Association); if (associationSetMapping != null) { navigationPropertyConfiguration.Configure(associationSetMapping, databaseMapping); } } }
public void GetNavigationProperty_should_return_correct_property() { var entityType = new EdmEntityType(); var associationType = new EdmAssociationType().Initialize(); var property = entityType.AddNavigationProperty("Foo", associationType); var foundProperty = entityType.GetNavigationProperty("Foo"); Assert.NotNull(foundProperty); Assert.Same(property, foundProperty); }