From 2f912fa94ceecfaaeca831dc221172ca6a92884d Mon Sep 17 00:00:00 2001 From: Jonas Rapp Date: Sat, 1 Feb 2020 10:56:09 +0100 Subject: [PATCH] Fixed #44 Relationships filters improved --- LCG-UDG/LCG.cs | 10 +++++++--- LCG-UDG/Metadata/RelationshipMetadataProxy.cs | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/LCG-UDG/LCG.cs b/LCG-UDG/LCG.cs index 30b431b..b3500e3 100644 --- a/LCG-UDG/LCG.cs +++ b/LCG-UDG/LCG.cs @@ -654,15 +654,19 @@ private IEnumerable GetFilteredRelationships(EntityMe { bool GetTypeFilter(RelationshipMetadataProxy r) { // Exclude relationships where selected entity is just child of the relationship - if (settings.RelationshipFilter.Type1N && r.OneToManyRelationshipMetadata?.ReferencingEntity == entity?.LogicalName) + if (settings.RelationshipFilter.Type1N && + r.OneToManyRelationshipMetadata?.ReferencedEntity == entity?.LogicalName) { return true; } - if (settings.RelationshipFilter.TypeN1 && r.OneToManyRelationshipMetadata?.ReferencedEntity == entity?.LogicalName) + if (settings.RelationshipFilter.TypeN1 && + r.OneToManyRelationshipMetadata?.ReferencingEntity == entity?.LogicalName && + r.OneToManyRelationshipMetadata?.ReferencedEntity != entity?.LogicalName) // Exclude self-referencing relationships, they are included as 1:N { return true; } - if (settings.RelationshipFilter.TypeNN && r.Metadata.RelationshipType == RelationshipType.ManyToManyRelationship) + if (settings.RelationshipFilter.TypeNN && + r.Metadata.RelationshipType == RelationshipType.ManyToManyRelationship) { return true; } diff --git a/LCG-UDG/Metadata/RelationshipMetadataProxy.cs b/LCG-UDG/Metadata/RelationshipMetadataProxy.cs index 90c0dc9..1ae1a8a 100644 --- a/LCG-UDG/Metadata/RelationshipMetadataProxy.cs +++ b/LCG-UDG/Metadata/RelationshipMetadataProxy.cs @@ -64,7 +64,7 @@ internal AttributeMetadataProxy LookupAttribute [DisplayName("Type")] public string Type => Metadata.RelationshipType == RelationshipType.ManyToManyRelationship ? "N : N" : originatingentity == Parent ? "1 : N" : originatingentity == Child ? "N : 1" : "?"; - + [DisplayName("Related Entity")] public string RelatedEntityName => OtherEntity?.DisplayName; @@ -89,6 +89,10 @@ public string LookupName [DisplayName("Schema Name")] public string LogicalName => Metadata?.SchemaName; + // Two nice to have properties for debugging + //public string Referenced => Metadata.RelationshipType == RelationshipType.ManyToManyRelationship ? ManyToManyRelationshipMetadata.Entity1LogicalName : OneToManyRelationshipMetadata.ReferencedEntity + "/" + OneToManyRelationshipMetadata.ReferencedAttribute; + //public string Referencing => Metadata.RelationshipType == RelationshipType.ManyToManyRelationship ? ManyToManyRelationshipMetadata.Entity2LogicalName : OneToManyRelationshipMetadata.ReferencingEntity + "/" + OneToManyRelationshipMetadata.ReferencingAttribute; + public string Summary(Settings settings) { if (Metadata is ManyToManyRelationshipMetadata)