diff --git a/RDFSharp/Query/Mirella/Algebra/RDFPatternGroup.cs b/RDFSharp/Query/Mirella/Algebra/RDFPatternGroup.cs index 1c4259e4..781ad4a6 100644 --- a/RDFSharp/Query/Mirella/Algebra/RDFPatternGroup.cs +++ b/RDFSharp/Query/Mirella/Algebra/RDFPatternGroup.cs @@ -189,8 +189,12 @@ public RDFPatternGroup AddPropertyPath(RDFPropertyPath propertyPath) public RDFPatternGroup AddValues(RDFValues values) { if (values != null) - this.GroupMembers.Add(values); - + { + if (!this.GetValues().Any(v => v.Equals(values))) + { + this.GroupMembers.Add(values); + } + } return this; } @@ -268,7 +272,7 @@ internal RDFPatternGroup AddInjectedValues(RDFValues values) clonedValues.IsEvaluable = values.IsEvaluable; clonedValues.IsInjected = true; - this.GroupMembers.Add(clonedValues); + this.AddValues(clonedValues); } return this; } diff --git a/RDFSharp/Query/Mirella/RDFQueryEngine.cs b/RDFSharp/Query/Mirella/RDFQueryEngine.cs index 727547be..72ecb715 100644 --- a/RDFSharp/Query/Mirella/RDFQueryEngine.cs +++ b/RDFSharp/Query/Mirella/RDFQueryEngine.cs @@ -605,7 +605,9 @@ internal void EvaluatePatternGroup(RDFQuery query, RDFPatternGroup patternGroup, QueryMemberTemporaryResultTables[patternGroup.QueryMemberID] = new List(); //Iterate the evaluable members of the pattern group - List evaluablePGMembers = patternGroup.GetEvaluablePatternGroupMembers().ToList(); + List evaluablePGMembers = patternGroup.GetEvaluablePatternGroupMembers() + .Distinct() + .ToList(); foreach (RDFPatternGroupMember evaluablePGMember in evaluablePGMembers) {