public void Matches_navigation_plus_PK_name_property() { var fkProperty = DependentType.Property(DependentEntity.SomeNavPeEKaYProperty, ConfigurationSource.Convention).Metadata; DependentType.Property(DependentEntity.SomeNavIDProperty, ConfigurationSource.Convention); DependentType.Property(DependentEntity.PrincipalEntityIDProperty, ConfigurationSource.Convention); DependentType.Property(DependentEntity.PrincipalEntityPeEKaYProperty, ConfigurationSource.Convention); DependentType.Property(DependentEntity.PeEKaYProperty, ConfigurationSource.Convention); var relationshipBuilder = DependentType.Relationship( PrincipalType, "SomeNav", null, ConfigurationSource.Convention); var newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(relationshipBuilder); Assert.NotSame(relationshipBuilder, newRelationshipBuilder); var fk = (IForeignKey)DependentType.Metadata.GetForeignKeys().Single(); Assert.Same(fk, newRelationshipBuilder.Metadata); Assert.Same(fkProperty, fk.Properties.Single()); Assert.Same(PrimaryKey, fk.PrincipalKey.Properties.Single()); Assert.False(fk.IsUnique); Assert.True(fk.IsRequired); }
public static ContainerBuilder RegisterAll ( Dictionary <Type, Type> repositoryKeyTypes, Type repositoryKeyTypeDefault, string connectionStringKeyBedrock, Assembly bootstrapAssembly, Assembly[] serviceAssemblies, Assembly[] domainAssemblies, Assembly webAssembly, CoreConfiguration.BedrockConfiguration bedrockConfiguration, IocConfiguration iocConfiguration, DependentType dependentType ) { return(RegisterBase ( repositoryKeyTypes, repositoryKeyTypeDefault, connectionStringKeyBedrock, bootstrapAssembly, serviceAssemblies, domainAssemblies, webAssembly, bedrockConfiguration, iocConfiguration, dependentType ) .RegisterSecurity(iocConfiguration)); }
public void Foreign_key_matching_given_property_is_found() { DependentType.GetOrAddProperty("SomeNavID", typeof(int), shadowProperty: true); DependentType.GetOrAddProperty("SomeNavPeEKaY", typeof(int), shadowProperty: true); DependentType.GetOrAddProperty("PrincipalEntityID", typeof(int), shadowProperty: true); DependentType.GetOrAddProperty("PrincipalEntityPeEKaY", typeof(int), shadowProperty: true); var fkProperty1 = DependentType.GetOrAddProperty("No", typeof(int), shadowProperty: true); var fkProperty2 = DependentType.GetOrAddProperty("IAmYourFk", typeof(int), shadowProperty: true); var fk = DependentType.GetOrAddForeignKey(new[] { fkProperty1, fkProperty2 }, PrincipalType.GetOrAddKey( new[] { PrincipalType.GetOrAddProperty("Id1", typeof(int), shadowProperty: true), PrincipalType.GetOrAddProperty("Id2", typeof(int), shadowProperty: true) })); Assert.Same( fk, new ForeignKeyConvention().TryGetForeignKey( PrincipalType, DependentType, "SomeNav", "SomeInverse", new[] { fkProperty1, fkProperty2 }, new Property[0], isUnique: false)); }
public void Does_not_invert_if_both_entity_types_can_have_non_pk_fk_property() { DependentType.Property(DependentEntity.PeEKaYProperty, ConfigurationSource.Convention); PrincipalType.Property(PrincipalEntity.DependentEntityKayPeeProperty, ConfigurationSource.Convention); var relationshipBuilder = DependentType.Relationship( DependentType, PrincipalType, null, null, null, null, ConfigurationSource.Convention, isUnique: true); var newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(relationshipBuilder); Assert.NotSame(relationshipBuilder, newRelationshipBuilder); Assert.Same(PrincipalType.Metadata, newRelationshipBuilder.Metadata.EntityType); newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(newRelationshipBuilder); var fk = (IForeignKey)newRelationshipBuilder.Metadata; Assert.Same(DependentType.Metadata.GetPrimaryKey(), fk.PrincipalKey); Assert.True(fk.IsUnique); Assert.False(fk.IsRequired); }
public void Does_not_invert_if_both_entity_types_have_navigations() { var relationshipBuilder = DependentType.Relationship( DependentType, PrincipalType, "InverseReferenceNav", "SomeNav", null, null, ConfigurationSource.Convention, isUnique: true); var newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(relationshipBuilder); Assert.NotSame(relationshipBuilder, newRelationshipBuilder); Assert.Same(PrincipalType.Metadata, newRelationshipBuilder.Metadata.EntityType); newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(newRelationshipBuilder); var fk = (IForeignKey)PrincipalType.Metadata.GetForeignKeys().Single(); Assert.Same(fk, newRelationshipBuilder.Metadata); Assert.Same(DependentType.Metadata.GetPrimaryKey(), fk.PrincipalKey); Assert.True(fk.IsUnique); Assert.True(fk.IsRequired); Assert.Empty(DependentType.Metadata.GetForeignKeys()); }
public void Inverts_if_principal_entity_type_can_have_nullable_fk_property_for_non_required_relationship() { DependentType.Property(DependentEntity.PeEKaYProperty, ConfigurationSource.Convention); var fkProperty = PrincipalType.Property(PrincipalEntity.DependentEntityKayPeeProperty, ConfigurationSource.Convention).Metadata; var relationshipBuilder = DependentType.Relationship( PrincipalType, DependentType, null, null, null, null, ConfigurationSource.Convention, isUnique: true, isRequired: false); var newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(relationshipBuilder); Assert.NotSame(relationshipBuilder, newRelationshipBuilder); Assert.Same(PrincipalType.Metadata, newRelationshipBuilder.Metadata.EntityType); newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(newRelationshipBuilder); var fk = (IForeignKey)PrincipalType.Metadata.GetForeignKeys().Single(); Assert.Same(fk, newRelationshipBuilder.Metadata); Assert.Same(fkProperty, fk.Properties.Single()); Assert.Same(DependentType.Metadata.GetPrimaryKey(), fk.PrincipalKey); Assert.True(fk.IsUnique); Assert.False(fk.IsRequired); Assert.Empty(DependentType.Metadata.GetForeignKeys()); }
public void Does_not_invert_if_both_are_referenced() { DependentType.Relationship( PrincipalType, DependentType, null, null, null, null, ConfigurationSource.Convention); DependentType.Relationship( DependentType, PrincipalType, null, null, null, null, ConfigurationSource.Convention); var relationshipBuilder = DependentType.Relationship( DependentType, PrincipalType, null, null, null, null, ConfigurationSource.Convention, isUnique: true); var newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(relationshipBuilder); Assert.NotSame(relationshipBuilder, newRelationshipBuilder); Assert.Same(PrincipalType.Metadata, newRelationshipBuilder.Metadata.EntityType); newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(newRelationshipBuilder); var fk = (IForeignKey)newRelationshipBuilder.Metadata; Assert.Same(DependentType.Metadata.GetPrimaryKey(), fk.PrincipalKey); Assert.True(fk.IsUnique); Assert.True(fk.IsRequired); }
public void Inverts_if_dependent_entity_type_is_referenced() { DependentType.Relationship( PrincipalType, DependentType, null, null, null, null, ConfigurationSource.Convention); var relationshipBuilder = DependentType.Relationship( DependentType, PrincipalType, null, null, null, null, ConfigurationSource.Convention, isUnique: true); var newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(relationshipBuilder); Assert.NotSame(relationshipBuilder, newRelationshipBuilder); Assert.Same(DependentType.Metadata, newRelationshipBuilder.Metadata.EntityType); newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(newRelationshipBuilder); var fk = (IForeignKey)newRelationshipBuilder.Metadata; Assert.Same(PrimaryKey, fk.PrincipalKey.Properties.Single()); Assert.True(fk.IsUnique); Assert.True(fk.IsRequired); Assert.Empty(PrincipalType.Metadata.GetForeignKeys()); }
public void Does_nothing_if_a_foreign_key_on_the_best_candidate_property_already_exists() { var fkProperty = DependentType.Property(DependentEntity.SomeNavPeEKaYProperty, ConfigurationSource.Convention).Metadata; DependentType.Property(DependentEntity.PrincipalEntityIDProperty, ConfigurationSource.Convention); DependentType.Property(DependentEntity.PrincipalEntityPeEKaYProperty, ConfigurationSource.Convention); DependentType.Property(DependentEntity.PeEKaYProperty, ConfigurationSource.Convention); var relationshipBuilder = DependentType.HasForeignKey( PrincipalType, new[] { fkProperty }, ConfigurationSource.Convention); var fk = (IForeignKey)relationshipBuilder.Metadata; Assert.Same(fkProperty, fk.Properties.Single()); Assert.False(fk.IsUnique); Assert.True(fk.IsRequired); relationshipBuilder = DependentType.Relationship( PrincipalType, "SomeNav", null, ConfigurationSource.Convention); Assert.Same(relationshipBuilder, new ForeignKeyPropertyDiscoveryConvention().Apply(relationshipBuilder)); var newFk = (IForeignKey)relationshipBuilder.Metadata; Assert.Equal(2, DependentType.Metadata.GetForeignKeys().Count()); Assert.NotEqual(fkProperty.Name, newFk.Properties.Single().Name); }
public void Does_not_invert_if_dependent_entity_type_can_have_non_pk_fk_property() { var fkProperty = DependentType.Property(DependentEntity.PeEKaYProperty, ConfigurationSource.Convention).Metadata; var relationshipBuilder = DependentType.Relationship( PrincipalType, DependentType, null, null, null, null, ConfigurationSource.Convention, isUnique: true); var newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(relationshipBuilder); Assert.NotSame(relationshipBuilder, newRelationshipBuilder); Assert.Same(DependentType.Metadata, newRelationshipBuilder.Metadata.EntityType); newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(newRelationshipBuilder); var fk = (IForeignKey)DependentType.Metadata.GetForeignKeys().Single(); Assert.Same(fk, newRelationshipBuilder.Metadata); Assert.Same(fkProperty, fk.Properties.Single()); Assert.Same(PrimaryKey, fk.PrincipalKey.Properties.Single()); Assert.True(fk.IsUnique); Assert.True(fk.IsRequired); }
public void Creates_foreign_key_using_given_dependent_and_principal_properties() { DependentType.GetOrAddProperty("SomeNavID", typeof(int), shadowProperty: true); DependentType.GetOrAddProperty("SomeNavPeEKaY", typeof(int), shadowProperty: true); DependentType.GetOrAddProperty("PrincipalEntityID", typeof(int), shadowProperty: true); DependentType.GetOrAddProperty("PrincipalEntityPeEKaY", typeof(int), shadowProperty: true); var fkProperty1 = DependentType.GetOrAddProperty("ThatsNotTrue!", typeof(int), shadowProperty: true); var fkProperty2 = DependentType.GetOrAddProperty("ThatsImpossible!", typeof(int), shadowProperty: true); var principalKeyProperty1 = PrincipalType.GetOrAddProperty("SearchYourFeelings", typeof(int), shadowProperty: true); var principalKeyProperty2 = PrincipalType.GetOrAddProperty("YouKnowItToBeTrue!", typeof(int), shadowProperty: true); var fk = (IForeignKey) new ForeignKeyConvention().FindOrCreateForeignKey( PrincipalType, DependentType, "SomeNav", "SomeInverse", new[] { fkProperty1, fkProperty2 }, new[] { principalKeyProperty1, principalKeyProperty2 }, isUnique: false); Assert.Same(fkProperty1, fk.Properties[0]); Assert.Same(fkProperty2, fk.Properties[1]); Assert.Same(principalKeyProperty1, fk.ReferencedProperties[0]); Assert.Same(principalKeyProperty2, fk.ReferencedProperties[1]); Assert.False(fk.IsUnique); Assert.True(fk.IsRequired); }
public void Inverts_and_sets_foreign_key_if_matching_non_shadow_property_added_on_principal_type() { var relationshipBuilder = PrincipalType .Relationship(DependentType, "InverseReferenceNav", "SomeNav", ConfigurationSource.Convention) .IsUnique(true, ConfigurationSource.Convention); var fk = (IForeignKey)relationshipBuilder.Metadata; Assert.Same(fk, PrincipalType.Metadata.GetForeignKeys().Single()); Assert.Equal("InverseReferenceNavKayPee", fk.Properties.Single().Name); Assert.Same(fk.DeclaringEntityType, PrincipalType.Metadata); Assert.Same(fk.PrincipalEntityType, DependentType.Metadata); Assert.True(fk.IsUnique); var property = DependentType.Property(DependentEntity.SomeNavIDProperty, ConfigurationSource.Convention); Assert.Same(property, new ForeignKeyPropertyDiscoveryConvention().Apply(property)); Assert.Same(property, new ForeignKeyPropertyDiscoveryConvention().Apply(property)); var newFk = DependentType.Metadata.GetForeignKeys().Single(); Assert.NotSame(fk, newFk); Assert.Equal(property.Metadata, newFk.Properties.Single()); Assert.Same(newFk.DeclaringEntityType, fk.PrincipalEntityType); Assert.Same(newFk.PrincipalEntityType, fk.DeclaringEntityType); Assert.True(newFk.IsUnique); }
public void Creates_foreign_key_using_given_properties() { DependentType.GetOrAddProperty("SomeNavID", typeof(int), shadowProperty: true); DependentType.GetOrAddProperty("SomeNavPeEKaY", typeof(int), shadowProperty: true); DependentType.GetOrAddProperty("PrincipalEntityID", typeof(int), shadowProperty: true); DependentType.GetOrAddProperty("PrincipalEntityPeEKaY", typeof(int), shadowProperty: true); var fkProperty1 = DependentType.GetOrAddProperty("ThatsNotTrue!", typeof(int), shadowProperty: true); var fkProperty2 = DependentType.GetOrAddProperty("ThatsImpossible!", typeof(int?), shadowProperty: true); var fk = (IForeignKey) new ForeignKeyConvention().FindOrCreateForeignKey( PrincipalType, DependentType, "SomeNav", "SomeInverse", new[] { fkProperty1, fkProperty2 }, new Property[0], isUnique: false); Assert.Same(fkProperty1, fk.Properties[0]); Assert.Same(fkProperty2, fk.Properties[1]); Assert.Equal(2, fk.ReferencedProperties.Count); Assert.Equal("ThatsNotTrue!Key", fk.ReferencedProperties[0].Name); Assert.Same(typeof(int), fk.ReferencedProperties[0].PropertyType); Assert.True(fk.ReferencedProperties[0].IsShadowProperty); Assert.Equal("ThatsImpossible!Key", fk.ReferencedProperties[1].Name); Assert.Same(typeof(int), fk.ReferencedProperties[1].PropertyType); Assert.True(fk.ReferencedProperties[1].IsShadowProperty); Assert.False(fk.IsUnique); Assert.False(fk.IsRequired); }
public static void SetWebRequestLifeTimeScope(DependentType dependentType, IRegistrationBuilder <object, ConcreteReflectionActivatorData, SingleRegistrationStyle> registration) { switch (dependentType) { case DependentType.AspNetCore: { registration.InstancePerLifetimeScope(); break; } case DependentType.Web: case DependentType.WebApi: case DependentType.WebUI: { registration.InstancePerRequest(); break; } default: { registration.SingleInstance(); break; } } }
public async Task TestGet_CheckProperties() { var dependentType = new DependentType { Name = "name", DependentTypeId = 1, SevisDependentTypeCode = "code" }; context.DependentTypes.Add(dependentType); Action <PagedQueryResults <DependentTypeDTO> > tester = (results) => { Assert.AreEqual(1, results.Total); Assert.AreEqual(1, results.Results.Count); var firstResult = results.Results.First(); Assert.AreEqual(dependentType.DependentTypeId, firstResult.Id); Assert.AreEqual(dependentType.Name, firstResult.Name); Assert.AreEqual(dependentType.SevisDependentTypeCode, firstResult.SevisDependentTypeCode); }; var defaultSorter = new ExpressionSorter <DependentTypeDTO>(x => x.Id, SortDirection.Ascending); var queryOperator = new QueryableOperator <DependentTypeDTO>(0, 10, defaultSorter); var serviceResults = service.Get(queryOperator); var serviceResultsAsync = await service.GetAsync(queryOperator); tester(serviceResults); tester(serviceResultsAsync); }
public void Matches_dependent_PK_for_unique_FK() { var fkProperty = DependentType.Metadata.GetPrimaryKey().Properties.Single(); var relationshipBuilder = DependentType.Relationship( PrincipalType, DependentType, "SomeNav", "InverseReferenceNav", null, PrincipalType.Metadata.GetPrimaryKey().Properties, ConfigurationSource.Convention, isUnique: true); var newRelationshipBuilder = new ForeignKeyPropertyDiscoveryConvention().Apply(relationshipBuilder); Assert.NotSame(relationshipBuilder, newRelationshipBuilder); var fk = (IForeignKey)DependentType.Metadata.GetForeignKeys().Single(); Assert.Same(fk, newRelationshipBuilder.Metadata); Assert.Same(fkProperty, fk.Properties.Single()); Assert.Same(PrimaryKey, fk.PrincipalKey.Properties.Single()); Assert.True(fk.IsUnique); Assert.True(fk.IsRequired); }
public void Does_not_override_explicit_foreign_key_created_using_given_property() { DependentType.Property(DependentEntity.SomeNavIDProperty, ConfigurationSource.Convention); DependentType.Property(DependentEntity.SomeNavPeEKaYProperty, ConfigurationSource.Convention); DependentType.Property(DependentEntity.PrincipalEntityIDProperty, ConfigurationSource.Convention); DependentType.Property(DependentEntity.PrincipalEntityPeEKaYProperty, ConfigurationSource.Convention); DependentType.Property(DependentEntity.IDProperty, ConfigurationSource.Convention); DependentType.Property(DependentEntity.PeEKaYProperty, ConfigurationSource.Convention); var fkProperty = DependentType.Property("No!No!", typeof(int), ConfigurationSource.Convention).Metadata; var relationshipBuilder = DependentType.Relationship( PrincipalType, "SomeNav", null, ConfigurationSource.Explicit) .HasForeignKey(new[] { fkProperty }, ConfigurationSource.Explicit); Assert.Same(relationshipBuilder, new ForeignKeyPropertyDiscoveryConvention().Apply(relationshipBuilder)); var fk = (IForeignKey)relationshipBuilder.Metadata; Assert.Same(fk, DependentType.Metadata.GetForeignKeys().Single()); Assert.Same(fkProperty, fk.Properties.Single()); Assert.Same(PrimaryKey, fk.PrincipalKey.Properties.Single()); Assert.False(fk.IsUnique); Assert.True(fk.IsRequired); }
public void Does_not_match_non_nullable_dependent_PK_for_optional_unique_FK() { var fkProperty = DependentType.Metadata.GetPrimaryKey().Properties.Single(); var relationshipBuilder = DependentType.Relationship( PrincipalType, DependentType, "SomeNav", "InverseReferenceNav", null, PrincipalType.Metadata.GetPrimaryKey().Properties, ConfigurationSource.Convention, isUnique: true, isRequired: false); Assert.Same(relationshipBuilder, new ForeignKeyPropertyDiscoveryConvention().Apply(relationshipBuilder)); var fk = (IForeignKey)relationshipBuilder.Metadata; Assert.NotSame(fkProperty, fk.Properties.Single()); Assert.Equal("SomeNav" + PrimaryKey.Name, fk.Properties.Single().Name); Assert.Same(PrimaryKey, fk.PrincipalKey.Properties.Single()); Assert.True(fk.IsUnique); Assert.False(fk.IsRequired); }
public override string ToString() { var name = Name != null ? Name.Name + ": " : ""; var genArgs = Arguments.Select((arg) => $"({arg.Depth},{arg.Index})").InterleaveCommas(); return($"{name}{DependentType.ToString ()}<{genArgs}>"); }
public void Foreign_key_matching_principal_type_name_plus_PK_name_is_found() { var fkProperty = DependentType.AddProperty("PrincipalEntityPeEKaY", typeof(int)); var fk = DependentType.AddForeignKey(PrincipalType.GetKey(), fkProperty); Assert.Same(fk, new ForeignKeyConvention().FindOrCreateForeignKey(PrincipalType, DependentType, "SomeNav", "SomeInverse", isUnqiue: false)); }
public static ContainerBuilder Bootstrap(DependentType dependentType, string connectionStringKeyBedrock, CoreConfiguration.BedrockConfiguration bedrockConfiguration) { DependentType = dependentType; ConnectionStringKeyBedrock = connectionStringKeyBedrock; BedrockConfiguration = bedrockConfiguration; IocConfiguration = IocConfiguration.Current; return(CreateContainerBuilder()); }
public void Creates_unique_foreign_key_using_dependent_PK_if_no_matching_FK_property_found() { var fk = new ForeignKeyConvention().FindOrCreateForeignKey(PrincipalType, DependentType, "SomeNav", "SomeInverse", isUnqiue: true); Assert.Same(DependentType.GetKey().Properties.Single(), fk.Properties.Single()); Assert.Same(PrimaryKey, fk.ReferencedProperties.Single()); Assert.True(fk.IsUnique); Assert.True(fk.IsRequired); }
public void Foreign_key_matching_principal_type_name_plus_Id_is_found() { var fkProperty = DependentType.GetOrAddProperty("PrincipalEntityID", typeof(int), shadowProperty: true); DependentType.GetOrAddProperty("PrincipalEntityPeEKaY", typeof(int), shadowProperty: true); var fk = DependentType.GetOrAddForeignKey(fkProperty, PrincipalType.GetPrimaryKey()); Assert.Same(fk, new ForeignKeyConvention().FindOrCreateForeignKey(PrincipalType, DependentType, "SomeNav", "SomeInverse", isUnqiue: false)); }
public async Task <DependentType> GetDependentTypeByIdAsync(int dependentTypeId) { DependentType dependentType = await _paylocityDbContext .DependentTypes .FindAsync(dependentTypeId) .ConfigureAwait(false); return(dependentType); }
public void Creates_foreign_key_matching_principal_type_name_plus_PK_name() { var fkProperty = DependentType.AddProperty("PrincipalEntityPeEKaY", typeof(int)); var fk = new ForeignKeyConvention().FindOrCreateForeignKey(PrincipalType, DependentType, "SomeNav", "SomeInverse", isUnqiue: false); Assert.Same(fkProperty, fk.Properties.Single()); Assert.Same(PrimaryKey, fk.ReferencedProperties.Single()); Assert.False(fk.IsUnique); Assert.True(fk.IsRequired); }
public void TestCreateGetRelatedPersonByDependentFamilyMemberQuery_CheckProperties() { var spousePersonType = new DependentType { DependentTypeId = DependentType.Spouse.Id }; var gender = new Gender { GenderId = Gender.Female.Id, GenderName = Gender.Female.Value }; var person = new Person { PersonId = 10, GenderId = gender.GenderId, Gender = gender }; var dependent = new PersonDependent { DependentTypeId = spousePersonType.DependentTypeId, DependentId = 2, PersonId = person.PersonId, FirstName = "firstName", LastName = "lastName", NameSuffix = "III", GenderId = gender.GenderId, Person = person }; var status = new ParticipantStatus { ParticipantStatusId = 1, Status = "status" }; var participant = new Participant { Status = status, Person = person, }; context.ParticipantStatuses.Add(status); person.Participations.Add(participant); person.Family.Add(dependent); context.People.Add(person); context.PersonDependents.Add(dependent); context.DependentTypes.Add(spousePersonType); var result = PersonQueries.CreateGetRelatedPersonByDependentFamilyMemberQuery(context, dependent.DependentId).FirstOrDefault(); Assert.IsNotNull(result); Assert.AreEqual(person.PersonId, result.PersonId); }
/// <summary> /// Registers common application dependencies /// </summary> /// <param name="bootstrapAssembly">Used to scan for types</param> /// <param name="serviceAssemblies">Used to scan for types</param> /// <param name="domainAssemblies">Used to scan for types</param> /// <param name="dependentType">Type of application</param> /// <param name="bedrockConfiguration">If NetCoreApp application, must be passed in, or registration will throw. If Framework application, will be built here, so no need to pass in.</param> /// <returns>Current builder</returns> public static ContainerBuilder RegisterAll ( Assembly bootstrapAssembly = null, Assembly[] serviceAssemblies = null, Assembly[] domainAssemblies = null, DependentType dependentType = DependentType.Default, CoreConfiguration.BedrockConfiguration bedrockConfiguration = null, IocConfiguration iocConfiguration = null ) { return(RegisterAll(CreateContainerBuilder(bootstrapAssembly), bootstrapAssembly, serviceAssemblies, domainAssemblies, dependentType, bedrockConfiguration, iocConfiguration)); }
public static PersonType ConvertDependentTypeToPersonType(DependentType type) { switch (type) { case DependentType.Child: return(PersonType.Child); case DependentType.Spouse: return(PersonType.Spouse); default: throw new ArgumentOutOfRangeException(); } }
public void Does_not_match_dependent_PK_for_non_unique_FK() { DependentType.PrimaryKey(new[] { DependentEntity.PrincipalEntityPeEKaYProperty }, ConfigurationSource.Explicit); var relationshipBuilder = DependentType.Relationship(PrincipalType, ConfigurationSource.Convention) .IsUnique(false, ConfigurationSource.Convention); Assert.Same(relationshipBuilder, new ForeignKeyPropertyDiscoveryConvention().Apply(relationshipBuilder)); var fk = (IForeignKey)relationshipBuilder.Metadata; Assert.Same(fk, DependentType.Metadata.GetForeignKeys().Single()); Assert.Equal(PrincipalType.Metadata.DisplayName() + PrimaryKey.Name, fk.Properties.Single().Name); Assert.False(fk.IsUnique); }
public void Foreign_key_matching_given_properties_is_found() { DependentType.AddProperty("SomeNavID", typeof(int)); DependentType.AddProperty("SomeNavPeEKaY", typeof(int)); DependentType.AddProperty("PrincipalEntityID", typeof(int)); DependentType.AddProperty("PrincipalEntityPeEKaY", typeof(int)); var fkProperty = DependentType.AddProperty("HeToldMeYouKilledMyFk", typeof(int)); var fk = DependentType.AddForeignKey(PrincipalType.GetKey(), fkProperty); Assert.Same( fk, new ForeignKeyConvention().FindOrCreateForeignKey( PrincipalType, DependentType, "SomeNav", "SomeInverse", new[] { new[] { fkProperty } }, isUnqiue: false)); }