diff --git a/MarkMpn.Sql4Cds.Engine/ExecutionPlan/BaseDataNode.cs b/MarkMpn.Sql4Cds.Engine/ExecutionPlan/BaseDataNode.cs index e86b91d3..b8880111 100644 --- a/MarkMpn.Sql4Cds.Engine/ExecutionPlan/BaseDataNode.cs +++ b/MarkMpn.Sql4Cds.Engine/ExecutionPlan/BaseDataNode.cs @@ -1171,7 +1171,8 @@ private bool TranslateFetchXMLCriteriaWithVirtualAttributes(NodeCompilationConte if (meta.LogicalName == "solution" && linkName != null && !new FetchEntityType { Items = items }.GetLinkEntities(true).Any(link => link.alias == linkName)) return false; - if ((op == @operator.ne || op == @operator.nebusinessid || op == @operator.neq || op == @operator.neuserid) && type != BooleanComparisonType.IsDistinctFrom) + if ((op == @operator.ne || op == @operator.nebusinessid || op == @operator.neq || op == @operator.neuserid || op == @operator.notlike) + && type != BooleanComparisonType.IsDistinctFrom) { // FetchXML not-equal type operators treat NULL as not-equal to values, but T-SQL treats them as not-not-equal. Add // an extra not-null condition to keep it compatible with T-SQL diff --git a/MarkMpn.Sql4Cds.Engine/ExecutionPlan/FetchXmlScan.cs b/MarkMpn.Sql4Cds.Engine/ExecutionPlan/FetchXmlScan.cs index a31a6801..5bbf37d6 100644 --- a/MarkMpn.Sql4Cds.Engine/ExecutionPlan/FetchXmlScan.cs +++ b/MarkMpn.Sql4Cds.Engine/ExecutionPlan/FetchXmlScan.cs @@ -1223,7 +1223,10 @@ private void AddNotNullFilters(ColumnList schema, Dictionary()) { - if (cond.@operator == @operator.@null || cond.@operator == @operator.ne || cond.@operator == @operator.nebusinessid || cond.@operator == @operator.neq || cond.@operator == @operator.neuserid) + if (cond.@operator == @operator.@null || cond.@operator == @operator.ne || cond.@operator == @operator.nebusinessid || + cond.@operator == @operator.neq || cond.@operator == @operator.neuserid || cond.@operator == @operator.notlike || + cond.@operator == @operator.notin || cond.@operator == @operator.notunder || cond.@operator == @operator.notbeginwith || + cond.@operator == @operator.notbetween || cond.@operator == @operator.notcontainvalues || cond.@operator == @operator.notendwith) continue; var fullname = (cond.entityname?.EscapeIdentifier() ?? alias) + "." + (cond.alias ?? cond.attribute).EscapeIdentifier(); diff --git a/MarkMpn.Sql4Cds.Engine/ExecutionPlan/FilterNode.cs b/MarkMpn.Sql4Cds.Engine/ExecutionPlan/FilterNode.cs index b7a1b94c..ae06d0df 100644 --- a/MarkMpn.Sql4Cds.Engine/ExecutionPlan/FilterNode.cs +++ b/MarkMpn.Sql4Cds.Engine/ExecutionPlan/FilterNode.cs @@ -107,12 +107,12 @@ private void AddNotNullColumns(NodeSchema schema, BooleanExpression filter, bool AddNotNullColumns(schema, n.Expression, !not); } - if (!not && filter is InPredicate inPred) + if (!not && filter is InPredicate inPred && !inPred.NotDefined) { AddNotNullColumn(schema, inPred.Expression); } - if (!not && filter is LikePredicate like) + if (!not && filter is LikePredicate like && !like.NotDefined) { AddNotNullColumn(schema, like.FirstExpression); AddNotNullColumn(schema, like.SecondExpression);