Skip to content

Commit

Permalink
Merge pull request #927 from Suxsem/master
Browse files Browse the repository at this point in the history
Fix C# code generation for linkentities with OR root filter
  • Loading branch information
rappen authored Jul 8, 2023
2 parents 1de4b7c + f27dd10 commit 252f2c9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions FetchXmlBuilder/Converters/CSharpCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private string GetFilterLbL(string entity, FilterExpression filter, string owner
var code = new StringBuilder();
filter.FilterHint = $"{ownerName}.{(ownerType == OwnersType.Root ? "Criteria" : ownerType == OwnersType.Link ? "LinkCriteria" : "Filters")}";
var rootfilters = filter.FilterHint.EndsWith("Criteria") || filter.FilterHint.EndsWith("Criteria.Filters");
if (ownerType == OwnersType.Sub)
if (ownerType == OwnersType.Sub || (ownerType == OwnersType.Link && (filter.FilterOperator == LogicalOperator.Or || !filter.Conditions.Any())))
{
filter.FilterHint = GetVarName($"{ownerName}.{(filter.FilterOperator == LogicalOperator.Or ? "Or" : "And")}".Replace(".Criteria", "").Replace(".LinkCriteria", ""), several);

Expand Down Expand Up @@ -591,7 +591,7 @@ private string GetFilterOI(string entity, FilterExpression filter, string ownerN
break;

default:
if (ownerType == OwnersType.Sub)
if (ownerType == OwnersType.Sub || (ownerType == OwnersType.Link && (filter.FilterOperator == LogicalOperator.Or || !filter.Conditions.Any())))
{
code.Append($"{Indent(indentslevel)}new FilterExpression({(filter.FilterOperator == LogicalOperator.Or ? "LogicalOperator.Or" : "")}){CRLF}{Indent(indentslevel++)}{{{CRLF}");
}
Expand Down Expand Up @@ -1416,4 +1416,4 @@ internal enum AroundBy
Parentheses,
Braces
}
}
}

0 comments on commit 252f2c9

Please sign in to comment.