コード例 #1
0
        private void ConfigureAssociations(EntityType entityType, EdmModel model)
        {
            DebugCheck.NotNull(entityType);
            DebugCheck.NotNull(model);

            foreach (var configuration in _navigationPropertyConfigurations)
            {
                var propertyInfo = configuration.Key;
                var navigationPropertyConfiguration = configuration.Value;
                var navigationProperty = entityType.GetNavigationProperty(propertyInfo);

                if (navigationProperty == null)
                {
                    var property = entityType.Properties.SingleOrDefault(p => p.GetClrPropertyInfo() == propertyInfo);
                    if (property != null
                        && property.ComplexType != null)
                    {
                        throw new InvalidOperationException(
                            Strings.InvalidNavigationPropertyComplexType(propertyInfo.Name, entityType.Name, property.ComplexType.Name));
                    }

                    throw Error.NavigationPropertyNotFound(propertyInfo.Name, entityType.Name);
                }

                // Don't configure inherited navigation properties
                if (entityType.DeclaredNavigationProperties.Any(np => np.GetClrPropertyInfo().IsSameAs(propertyInfo)))
                {
                    navigationPropertyConfiguration.Configure(navigationProperty, model, this);
                }
            }
        }
コード例 #2
0
        private void ConfigureAssociationMappings(
            DbDatabaseMapping databaseMapping, EntityType entityType, DbProviderManifest providerManifest)
        {
            DebugCheck.NotNull(databaseMapping);
            DebugCheck.NotNull(entityType);
            DebugCheck.NotNull(providerManifest);

            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, providerManifest);
                }
            }
        }
コード例 #3
0
        private void ConfigureAssociations(EntityType entityType, EdmModel model)
        {
            DebugCheck.NotNull(entityType);
            DebugCheck.NotNull(model);

            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);
            }
        }