private static CompositePrincipalKeyValueFactory CreateCompositeFactory(IKey key)
        {
            var dependentFactory         = new DependentKeyValueFactoryFactory();
            var principalKeyValueFactory = new CompositePrincipalKeyValueFactory(key);

            foreach (var foreignKey in key.FindReferencingForeignKeys())
            {
                var dependentKeyValueFactory = dependentFactory.CreateComposite(foreignKey);

                var factorySource = foreignKey as IDependentKeyValueFactorySource;
                if (factorySource != null)
                {
                    factorySource.DependentKeyValueFactory = dependentKeyValueFactory;
                }

                var mapSource = foreignKey as IDependentsMapFactorySource;
                if (mapSource != null)
                {
                    mapSource.DependentsMapFactory = () => new DependentsMap <object[]>(
                        foreignKey, principalKeyValueFactory, dependentKeyValueFactory);
                }
            }

            return(principalKeyValueFactory);
        }
        private static CompositePrincipalKeyValueFactory CreateCompositeFactory(IKey key)
        {
            var dependentFactory         = new DependentKeyValueFactoryFactory();
            var principalKeyValueFactory = new CompositePrincipalKeyValueFactory(key);

            foreach (var foreignKey in key.GetReferencingForeignKeys())
            {
                var dependentKeyValueFactory = dependentFactory.CreateComposite(foreignKey);

                SetFactories(
                    foreignKey,
                    dependentKeyValueFactory,
                    () => new DependentsMap <object[]>(foreignKey, principalKeyValueFactory, dependentKeyValueFactory));
            }

            return(principalKeyValueFactory);
        }