private static SimplePrincipalKeyValueFactory <TKey> CreateSimpleFactory <TKey>(IKey key) { var dependentFactory = new DependentKeyValueFactoryFactory(); var principalKeyValueFactory = new SimplePrincipalKeyValueFactory <TKey>(key.Properties.Single().GetPropertyAccessors()); foreach (var foreignKey in key.FindReferencingForeignKeys()) { var dependentKeyValueFactory = dependentFactory.CreateSimple <TKey>(foreignKey); var factorySource = foreignKey as IDependentKeyValueFactorySource; if (factorySource != null) { factorySource.DependentKeyValueFactory = dependentKeyValueFactory; } var mapSource = foreignKey as IDependentsMapFactorySource; if (mapSource != null) { mapSource.DependentsMapFactory = () => new DependentsMap <TKey>( 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); }