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);
        }
        private static SimplePrincipalKeyValueFactory <TKey> CreateSimpleFactory <TKey>(IKey key)
        {
            var dependentFactory         = new DependentKeyValueFactoryFactory();
            var principalKeyValueFactory = new SimplePrincipalKeyValueFactory <TKey>(key.Properties.Single());

            foreach (var foreignKey in key.GetReferencingForeignKeys())
            {
                var dependentKeyValueFactory = dependentFactory.CreateSimple <TKey>(foreignKey);

                SetFactories(
                    foreignKey,
                    dependentKeyValueFactory,
                    () => new DependentsMap <TKey>(foreignKey, principalKeyValueFactory, dependentKeyValueFactory));
            }

            return(principalKeyValueFactory);
        }