private IMutableSkipNavigation WithRightManyNavigation(MemberIdentity navigationMember, [NotNull] string inverseName) { Check.DebugAssert(Builder == null, "Expected no associated foreign key at this point"); var navigationName = navigationMember.Name; var conflictingNavigation = RelatedEntityType.FindNavigation(navigationName) as IConventionNavigation; var foreignKey = (ForeignKey)conflictingNavigation?.ForeignKey; if (conflictingNavigation?.GetConfigurationSource() == ConfigurationSource.Explicit) { InternalForeignKeyBuilder.ThrowForConflictingNavigation( foreignKey, DeclaringEntityType, RelatedEntityType, inverseName, navigationName); } using (((EntityType)RelatedEntityType).Model.ConventionDispatcher.DelayConventions()) { if (conflictingNavigation != null) { foreignKey.DeclaringEntityType.RemoveForeignKey(foreignKey); } else { var skipNavigation = RelatedEntityType.FindSkipNavigation(navigationMember.Name); if (skipNavigation != null) { return(skipNavigation); } } return(((EntityType)RelatedEntityType).Builder.HasSkipNavigation( navigationMember, (EntityType)DeclaringEntityType, ConfigurationSource.Explicit).Metadata); } }
private UserNotification ExpectRelatedEntity(RelatedEntityType relatedEntityType, int relatedEntityId, UserNotification notification) { switch (relatedEntityType) { case RelatedEntityType.itContract: notification.Itcontract_Id = relatedEntityId; _contractRepository.Setup(x => x.GetById(relatedEntityId)).Returns(new ItContract()); break; case RelatedEntityType.itProject: notification.ItProject_Id = relatedEntityId; _projectRepository.Setup(x => x.GetById(relatedEntityId)).Returns(new ItProject()); break; case RelatedEntityType.itSystemUsage: notification.ItSystemUsage_Id = relatedEntityId; _systemUsageRepository.Setup(x => x.GetSystemUsage(relatedEntityId)).Returns(new ItSystemUsage()); break; case RelatedEntityType.dataProcessingRegistration: notification.DataProcessingRegistration_Id = relatedEntityId; _dataProcessingRepository.Setup(x => x.GetById(relatedEntityId)).Returns(new DataProcessingRegistration()); break; } return(notification); }
protected virtual EntityType ResolveEntityType([NotNull] string entityTypeName) { if (DeclaringEntityType.Name == entityTypeName) { return((EntityType)DeclaringEntityType); } if (RelatedEntityType.Name == entityTypeName) { return((EntityType)RelatedEntityType); } if (DeclaringEntityType.DisplayName() == entityTypeName) { return((EntityType)DeclaringEntityType); } if (RelatedEntityType.DisplayName() == entityTypeName) { return((EntityType)RelatedEntityType); } if (DeclaringEntityType.HasSharedClrType && DeclaringEntityType.ShortName() == entityTypeName) { return((EntityType)DeclaringEntityType); } return(RelatedEntityType.HasSharedClrType && RelatedEntityType.ShortName() == entityTypeName ? (EntityType)RelatedEntityType : null); }
private InternalForeignKeyBuilder WithOneBuilder(MemberIdentity reference) { if (SkipNavigation != null) { // Note: we delayed setting the ConfigurationSource of SkipNavigation in HasMany() // so we can test it here and override if the skip navigation was originally found // by convention. if (((IConventionSkipNavigation)SkipNavigation).GetConfigurationSource() == ConfigurationSource.Explicit) { throw new InvalidOperationException( CoreStrings.ConflictingRelationshipNavigation( SkipNavigation.DeclaringEntityType.DisplayName() + "." + SkipNavigation.Name, RelatedEntityType.DisplayName() + (reference.Name == null ? "" : "." + reference.Name), SkipNavigation.DeclaringEntityType.DisplayName() + "." + SkipNavigation.Name, SkipNavigation.TargetEntityType.DisplayName() + (SkipNavigation.Inverse == null ? "" : "." + SkipNavigation.Inverse.Name))); } var navigationName = SkipNavigation.Name; var declaringEntityType = (EntityType)DeclaringEntityType; declaringEntityType.Model.Builder .RemoveAssociationEntityIfCreatedImplicitly( (EntityType)SkipNavigation.AssociationEntityType, removeSkipNavigations: true, ConfigurationSource.Explicit); Builder = declaringEntityType.Builder .HasRelationship( (EntityType)RelatedEntityType, navigationName, ConfigurationSource.Explicit, targetIsPrincipal: false); SkipNavigation = null; } var foreignKey = Builder.Metadata; var referenceName = reference.Name; if (referenceName != null && foreignKey.DependentToPrincipal != null && foreignKey.GetDependentToPrincipalConfigurationSource() == ConfigurationSource.Explicit && foreignKey.DependentToPrincipal.Name != referenceName) { InternalForeignKeyBuilder.ThrowForConflictingNavigation(foreignKey, referenceName, newToPrincipal: true); } return(reference.MemberInfo == null || CollectionMember == null ? Builder.HasNavigations( reference.Name, CollectionName, (EntityType)DeclaringEntityType, (EntityType)RelatedEntityType, ConfigurationSource.Explicit) : Builder.HasNavigations( reference.MemberInfo, CollectionMember, (EntityType)DeclaringEntityType, (EntityType)RelatedEntityType, ConfigurationSource.Explicit)); }
private InternalRelationshipBuilder WithOneBuilder(PropertyIdentity reference) { var referenceName = reference.Name; if (!Builder.Metadata.IsUnique && Builder.Metadata.PrincipalToDependent != null && Builder.Metadata.GetPrincipalToDependentConfigurationSource() == ConfigurationSource.Explicit && referenceName != null) { ThrowForConflictingNavigation(Builder.Metadata, referenceName, false); } var builder = Builder.IsUnique(true, ConfigurationSource.Explicit); if (builder.Metadata.IsSelfReferencing() && referenceName != null && ReferenceName == referenceName) { throw new InvalidOperationException(CoreStrings.DuplicateNavigation( referenceName, RelatedEntityType.DisplayName(), RelatedEntityType.DisplayName())); } var pointsToPrincipal = !builder.Metadata.IsSelfReferencing() && (!builder.Metadata.DeclaringEntityType.IsAssignableFrom(DeclaringEntityType) || !builder.Metadata.PrincipalEntityType.IsAssignableFrom(RelatedEntityType) || (builder.Metadata.DeclaringEntityType.IsAssignableFrom(RelatedEntityType) && builder.Metadata.PrincipalEntityType.IsAssignableFrom(DeclaringEntityType) && builder.Metadata.PrincipalToDependent != null && builder.Metadata.PrincipalToDependent.Name == ReferenceName)); if (referenceName != null && ((pointsToPrincipal && builder.Metadata.DependentToPrincipal != null && builder.Metadata.GetDependentToPrincipalConfigurationSource() == ConfigurationSource.Explicit && builder.Metadata.DependentToPrincipal.Name != referenceName) || (!pointsToPrincipal && builder.Metadata.PrincipalToDependent != null && builder.Metadata.GetPrincipalToDependentConfigurationSource() == ConfigurationSource.Explicit && builder.Metadata.PrincipalToDependent.Name != referenceName))) { ThrowForConflictingNavigation(builder.Metadata, referenceName, pointsToPrincipal); } var referenceProperty = reference.Property; if (referenceProperty != null) { return(pointsToPrincipal ? builder.DependentToPrincipal(referenceProperty, ConfigurationSource.Explicit) : builder.PrincipalToDependent(referenceProperty, ConfigurationSource.Explicit)); } else { return(pointsToPrincipal ? builder.DependentToPrincipal(reference.Name, ConfigurationSource.Explicit) : builder.PrincipalToDependent(reference.Name, ConfigurationSource.Explicit)); } }
/// <summary> /// <para> /// Configures a relationship where this entity type has a reference that points /// to a single instance of the other type in the relationship. /// </para> /// <para> /// After calling this method, you should chain a call to /// <see cref="ReferenceNavigationBuilder{TEntity,TRelatedEntity} /// .WithMany(Expression{Func{TRelatedEntity,IEnumerable{TEntity}}})" /> /// or /// <see cref="ReferenceNavigationBuilder{TEntity,TRelatedEntity} /// .WithOne(Expression{Func{TRelatedEntity,TEntity}})" /> /// to fully configure the relationship. Calling just this method without the chained call will not /// produce a valid relationship. /// </para> /// </summary> /// <typeparam name="TNewRelatedEntity"> The entity type that this relationship targets. </typeparam> /// <param name="navigationExpression"> /// A lambda expression representing the reference navigation property on this entity type that represents /// the relationship (<c>post => post.Blog</c>). If no property is specified, the relationship will be /// configured without a navigation property on this end. /// </param> /// <returns> An object that can be used to configure the relationship. </returns> public virtual ReferenceNavigationBuilder <TRelatedEntity, TNewRelatedEntity> HasOne <TNewRelatedEntity>( [CanBeNull] Expression <Func <TRelatedEntity, TNewRelatedEntity> > navigationExpression = null) where TNewRelatedEntity : class { var relatedEntityType = RelatedEntityType.FindInDefinitionPath(typeof(TNewRelatedEntity)) ?? Builder.ModelBuilder.Entity(typeof(TNewRelatedEntity), ConfigurationSource.Explicit).Metadata; var navigation = navigationExpression?.GetPropertyAccess(); return(new ReferenceNavigationBuilder <TRelatedEntity, TNewRelatedEntity>( RelatedEntityType, relatedEntityType, navigation, RelatedEntityType.Builder.Navigation(relatedEntityType.Builder, navigation, ConfigurationSource.Explicit, setTargetAsPrincipal: RelatedEntityType == relatedEntityType))); }
private InternalRelationshipBuilder WithOneBuilder( MemberIdentity reference, Action <NavigationBuilder> navigationConfiguration = null) { if (SkipNavigation != null) { throw new InvalidOperationException( CoreStrings.ConflictingRelationshipNavigation( SkipNavigation.DeclaringEntityType.DisplayName() + "." + SkipNavigation.Name, RelatedEntityType.DisplayName() + (reference.Name == null ? "" : "." + reference.Name), SkipNavigation.DeclaringEntityType.DisplayName() + "." + SkipNavigation.Name, SkipNavigation.TargetEntityType.DisplayName() + (SkipNavigation.Inverse == null ? "" : "." + SkipNavigation.Inverse.Name))); } var foreignKey = Builder.Metadata; var referenceName = reference.Name; if (referenceName != null && foreignKey.DependentToPrincipal != null && foreignKey.GetDependentToPrincipalConfigurationSource() == ConfigurationSource.Explicit && foreignKey.DependentToPrincipal.Name != referenceName) { InternalRelationshipBuilder.ThrowForConflictingNavigation(foreignKey, referenceName, newToPrincipal: true); } var withOneBuilder = reference.MemberInfo == null || CollectionMember == null ? Builder.HasNavigations( reference.Name, CollectionName, (EntityType)DeclaringEntityType, (EntityType)RelatedEntityType, ConfigurationSource.Explicit) : Builder.HasNavigations( reference.MemberInfo, CollectionMember, (EntityType)DeclaringEntityType, (EntityType)RelatedEntityType, ConfigurationSource.Explicit); if (navigationConfiguration != null && withOneBuilder.Metadata.DependentToPrincipal != null) { navigationConfiguration( new NavigationBuilder(withOneBuilder.Metadata.DependentToPrincipal)); } return(withOneBuilder); }
/// <summary> /// <para> /// Configures a relationship where this entity type has a reference that points /// to a single instance of the other type in the relationship. /// </para> /// <para> /// After calling this method, you should chain a call to /// <see cref="ReferenceNavigationBuilder.WithMany" /> /// or <see cref="ReferenceNavigationBuilder.WithOne" /> to fully configure /// the relationship. Calling just this method without the chained call will not /// produce a valid relationship. /// </para> /// </summary> /// <param name="relatedTypeName"> The name of the entity type that this relationship targets. </param> /// <param name="navigationName"> /// The name of the reference navigation property on this entity type that represents the relationship. If /// no property is specified, the relationship will be configured without a navigation property on this /// end. /// </param> /// <returns> An object that can be used to configure the relationship. </returns> public virtual ReferenceNavigationBuilder HasOne( [NotNull] string relatedTypeName, [CanBeNull] string navigationName = null) { Check.NotEmpty(relatedTypeName, nameof(relatedTypeName)); Check.NullButNotEmpty(navigationName, nameof(navigationName)); var relatedEntityType = RelatedEntityType.FindInDefinitionPath(relatedTypeName) ?? RelatedEntityType.Builder.ModelBuilder.Entity(relatedTypeName, ConfigurationSource.Explicit).Metadata; return(new ReferenceNavigationBuilder( RelatedEntityType, relatedEntityType, navigationName, RelatedEntityType.Builder.Navigation(relatedEntityType.Builder, navigationName, ConfigurationSource.Explicit, setTargetAsPrincipal: RelatedEntityType == relatedEntityType))); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> protected virtual EntityType ResolveEntityType([NotNull] string entityTypeName) { if (DeclaringEntityType.Name == entityTypeName) { return(DeclaringEntityType); } if (RelatedEntityType.Name == entityTypeName) { return(RelatedEntityType); } if (DeclaringEntityType.DisplayName() == entityTypeName) { return(DeclaringEntityType); } return(RelatedEntityType.DisplayName() == entityTypeName ? RelatedEntityType : null); }
private InternalForeignKeyBuilder HasPrincipalKeyBuilder( EntityType principalEntityType, string principalEntityTypeName, Func <InternalForeignKeyBuilder, InternalForeignKeyBuilder> hasPrincipalKey) { if (principalEntityType == null) { throw new InvalidOperationException( CoreStrings.PrincipalEntityTypeNotInRelationship( DeclaringEntityType.DisplayName(), RelatedEntityType.DisplayName(), principalEntityTypeName)); } using var batch = principalEntityType.Model.ConventionDispatcher.DelayConventions(); var builder = Builder.HasEntityTypes( principalEntityType, GetOtherEntityType(principalEntityType), ConfigurationSource.Explicit); builder = hasPrincipalKey(builder); return(batch.Run(builder)); }
private InternalRelationshipBuilder HasForeignKeyBuilder( EntityType dependentEntityType, string dependentEntityTypeName, Func <InternalRelationshipBuilder, EntityType, InternalRelationshipBuilder> hasForeignKey) { if (dependentEntityType == null) { throw new InvalidOperationException(CoreStrings.DependentEntityTypeNotInRelationship( DeclaringEntityType.DisplayName(), RelatedEntityType.DisplayName(), dependentEntityTypeName)); } using (var batch = dependentEntityType.Model.ConventionDispatcher.StartBatch()) { var builder = Builder.RelatedEntityTypes( GetOtherEntityType(dependentEntityType), dependentEntityType, ConfigurationSource.Explicit); builder = hasForeignKey(builder, dependentEntityType); return(batch.Run(builder)); } }
/// <summary> /// Returns the internal builder to be used when <see cref="WithOne" /> is called. /// </summary> /// <param name="reference"> /// The name of the reference navigation property on the other end of this relationship. /// If null, there is no navigation property on the other end of the relationship. /// </param> /// <returns> The internal builder to further configure the relationship. </returns> protected virtual InternalRelationshipBuilder WithOneBuilder([CanBeNull] string reference) { if (Builder.Metadata.IsSelfReferencing() && (reference != null) && (ReferenceName == reference)) { throw new InvalidOperationException(CoreStrings.DuplicateNavigation( reference, RelatedEntityType.DisplayName(), RelatedEntityType.DisplayName())); } var builder = Builder.IsUnique(true, ConfigurationSource.Explicit); var pointsToPrincipal = !builder.Metadata.IsSelfReferencing() && (!builder.Metadata.DeclaringEntityType.IsAssignableFrom(DeclaringEntityType) || !builder.Metadata.PrincipalEntityType.IsAssignableFrom(RelatedEntityType) || (builder.Metadata.DeclaringEntityType.IsAssignableFrom(RelatedEntityType) && builder.Metadata.PrincipalEntityType.IsAssignableFrom(DeclaringEntityType) && builder.Metadata.PrincipalToDependent != null && builder.Metadata.PrincipalToDependent.Name == ReferenceName)); return(pointsToPrincipal ? builder.DependentToPrincipal(reference, ConfigurationSource.Explicit) : builder.PrincipalToDependent(reference, ConfigurationSource.Explicit)); }
private bool RelatedEntityExists(int relatedEntityId, RelatedEntityType relatedEntityType) { switch (relatedEntityType) { case RelatedEntityType.itContract: var contractExists = _contractRepository.GetById(relatedEntityId); return(contractExists != null); case RelatedEntityType.itProject: var projectExists = _projectRepository.GetById(relatedEntityId); return(projectExists != null); case RelatedEntityType.itSystemUsage: var systemUsageExists = _systemUsageRepository.GetSystemUsage(relatedEntityId); return(systemUsageExists != null); case RelatedEntityType.dataProcessingRegistration: var dataProcessingRegistrationExists = _dataProcessingRepository.GetById(relatedEntityId); return(dataProcessingRegistrationExists.HasValue); default: return(false); } }
public HttpResponseMessage GetByOrganizationAndUser(int organizationId, int userId, RelatedEntityType relatedEntityType) { return(_userNotificationApplicationService .GetNotificationsForUser(organizationId, userId, relatedEntityType) .Select(x => x.OrderBy(y => y.Created)) .Match(value => Ok(ToDTOs(value)), FromOperationError)); }
private void SetupUserNotificationService(int numberOfNotifications, int orgId, int userId, RelatedEntityType relatedEntityType) { var notificationsList = new List<UserNotification>(); for (int i = 0; i < numberOfNotifications; i++) { notificationsList.Add(new UserNotification() { Id = A<int>() }); } _userNotificationService.Setup(x => x.GetNotificationsForUser(orgId, userId, relatedEntityType)).Returns(Result<IQueryable<UserNotification>, OperationError>.Success(notificationsList.AsQueryable())); }
public Result <IQueryable <UserNotification>, OperationError> GetNotificationsForUser(int organizationId, int userId, RelatedEntityType relatedEntityType) { if (!IsActiveUser(userId)) { return(new OperationError(OperationFailure.Forbidden)); } return(_userNotificationService.GetNotificationsForUser(organizationId, userId, relatedEntityType)); }
public Result <UserNotification, OperationError> AddUserNotification(int organizationId, int userToNotifyId, string name, string message, int relatedEntityId, RelatedEntityType relatedEntityType, NotificationType notificationType) { if (message == null) { throw new ArgumentNullException(nameof(message)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } using var transaction = _transactionManager.Begin(IsolationLevel.ReadCommitted); if (!RelatedEntityExists(relatedEntityId, relatedEntityType)) { transaction.Rollback(); return(new OperationError(OperationFailure.NotFound)); } var notification = new UserNotification(name, message, notificationType, organizationId, userToNotifyId, _operationClock.Now); switch (relatedEntityType) { case RelatedEntityType.itContract: notification.Itcontract_Id = relatedEntityId; break; case RelatedEntityType.itProject: notification.ItProject_Id = relatedEntityId; break; case RelatedEntityType.itSystemUsage: notification.ItSystemUsage_Id = relatedEntityId; break; case RelatedEntityType.dataProcessingRegistration: notification.DataProcessingRegistration_Id = relatedEntityId; break; default: return(new OperationError(OperationFailure.BadInput)); } var userNotification = _userNotificationRepository.Add(notification); transaction.Commit(); return(userNotification); }
public Result <IQueryable <UserNotification>, OperationError> GetNotificationsForUser(int organizationId, int userId, RelatedEntityType relatedEntityType) { return(Result <IQueryable <UserNotification>, OperationError> .Success(_userNotificationRepository.GetNotificationFromOrganizationByUserId(organizationId, userId, relatedEntityType))); }
public IEnumerable <DomainModel.Advice.Advice> GetByRelationIdAndType(int relationId, RelatedEntityType objectType) { return(_advicesRepository.Get(a => a.RelationId == relationId && a.Type == objectType)); }
public HttpResponseMessage GetNumberOfUnresolvedNotifications(int organizationId, int userId, RelatedEntityType relatedEntityType) { return(_userNotificationApplicationService .GetNotificationsForUser(organizationId, userId, relatedEntityType) .Select(x => x.Count()) .Match(value => Ok(value), FromOperationError)); }
public IQueryable <UserNotification> GetNotificationFromOrganizationByUserId(int organizationId, int userId, RelatedEntityType relatedEntityType) { var query = _repository .AsQueryable() .ByOrganizationId(organizationId) .Where(x => x.NotificationRecipientId == userId); switch (relatedEntityType) { case RelatedEntityType.itContract: return(query.Where(x => x.Itcontract_Id != null)); case RelatedEntityType.itProject: return(query.Where(x => x.ItProject_Id != null)); case RelatedEntityType.itSystemUsage: return(query.Where(x => x.ItSystemUsage_Id != null)); case RelatedEntityType.dataProcessingRegistration: return(query.Where(x => x.DataProcessingRegistration_Id != null)); default: throw new ArgumentOutOfRangeException(nameof(relatedEntityType)); } }
private InternalRelationshipBuilder WithOneBuilder(PropertyIdentity reference) { var referenceName = reference.Name; if (!Builder.Metadata.IsUnique && Builder.Metadata.PrincipalToDependent != null && Builder.Metadata.GetPrincipalToDependentConfigurationSource() == ConfigurationSource.Explicit && referenceName != null) { ThrowForConflictingNavigation(Builder.Metadata, referenceName, false); } using (var batch = Builder.Metadata.DeclaringEntityType.Model.ConventionDispatcher.StartBatch()) { var builder = Builder.IsUnique(true, ConfigurationSource.Explicit); var foreignKey = builder.Metadata; if (foreignKey.IsSelfReferencing() && referenceName != null && ReferenceName == referenceName) { throw new InvalidOperationException( CoreStrings.ConflictingPropertyOrNavigation( referenceName, RelatedEntityType.DisplayName(), RelatedEntityType.DisplayName())); } var pointsToPrincipal = !foreignKey.IsSelfReferencing() && (!foreignKey.DeclaringEntityType.IsAssignableFrom(DeclaringEntityType) || !foreignKey.PrincipalEntityType.IsAssignableFrom(RelatedEntityType) || (foreignKey.DeclaringEntityType.IsAssignableFrom(RelatedEntityType) && foreignKey.PrincipalEntityType.IsAssignableFrom(DeclaringEntityType) && foreignKey.PrincipalToDependent != null && foreignKey.PrincipalToDependent.Name == ReferenceName)); if (referenceName != null && ((pointsToPrincipal && foreignKey.DependentToPrincipal != null && foreignKey.GetDependentToPrincipalConfigurationSource() == ConfigurationSource.Explicit && foreignKey.DependentToPrincipal.Name != referenceName) || (!pointsToPrincipal && foreignKey.PrincipalToDependent != null && foreignKey.GetPrincipalToDependentConfigurationSource() == ConfigurationSource.Explicit && foreignKey.PrincipalToDependent.Name != referenceName))) { ThrowForConflictingNavigation(foreignKey, referenceName, pointsToPrincipal); } var referenceProperty = reference.MemberInfo; if (referenceName != null && pointsToPrincipal && RelatedEntityType != foreignKey.DeclaringEntityType) { builder = referenceProperty == null && ReferenceProperty == null ? builder.HasNavigations( referenceName, ReferenceName, (EntityType)DeclaringEntityType, (EntityType)RelatedEntityType, ConfigurationSource.Explicit) : builder.HasNavigations( referenceProperty, ReferenceProperty, (EntityType)DeclaringEntityType, (EntityType)RelatedEntityType, ConfigurationSource.Explicit); } else if (referenceName != null && !pointsToPrincipal && RelatedEntityType != foreignKey.PrincipalEntityType) { builder = referenceProperty == null && ReferenceProperty == null ? builder.HasNavigations( ReferenceName, referenceName, (EntityType)RelatedEntityType, (EntityType)DeclaringEntityType, ConfigurationSource.Explicit) : builder.HasNavigations( ReferenceProperty, referenceProperty, (EntityType)RelatedEntityType, (EntityType)DeclaringEntityType, ConfigurationSource.Explicit); } else { if (referenceProperty != null) { builder = builder.HasNavigation( referenceProperty, pointsToPrincipal, ConfigurationSource.Explicit); } else { builder = builder.HasNavigation( referenceName, pointsToPrincipal, ConfigurationSource.Explicit); } } return(batch.Run(builder)); } }
public IQueryable <UserNotification> GetByRelatedEntityIdAndType(int relatedEntityId, RelatedEntityType relatedEntityType) { switch (relatedEntityType) { case RelatedEntityType.itContract: return(_repository.AsQueryable().Where(x => x.Itcontract_Id == relatedEntityId)); case RelatedEntityType.itProject: return(_repository.AsQueryable().Where(x => x.ItProject_Id == relatedEntityId)); case RelatedEntityType.itSystemUsage: return(_repository.AsQueryable().Where(x => x.ItSystemUsage_Id == relatedEntityId)); case RelatedEntityType.dataProcessingRegistration: return(_repository.AsQueryable().Where(x => x.DataProcessingRegistration_Id == relatedEntityId)); default: throw new ArgumentOutOfRangeException(nameof(relatedEntityType)); } }