Factory()
public List> Group { get; } = new List>();
public IFilterExpression NextOperation { get; set; }
- public IFilterExpression LastOperation { get; set; }
+ public IFilterExpression PrevOperation { get; set; }
public IQueryFilter AddOperator(string expressionOperator, Expression> property)
{
@@ -40,7 +40,7 @@ public IQueryFilter AddOperator(string expressionOperator, Expression;
@@ -53,7 +53,7 @@ public IQueryFilter AddOperator(string expressionOperator, string property)
newOperation.PropertyName = property;
newOperation.PropertyType = typeof(object);
- newOperation.LastOperation = this;
+ newOperation.PrevOperation = this;
NextOperation = newOperation;
return newOperation;
diff --git a/src/Azure.EntityServices.Queries/HelperExtensions/DynamicQueryExtensions.cs b/src/Azure.EntityServices.Queries/HelperExtensions/DynamicQueryExtensions.cs
index 40765c5..14d4a31 100644
--- a/src/Azure.EntityServices.Queries/HelperExtensions/DynamicQueryExtensions.cs
+++ b/src/Azure.EntityServices.Queries/HelperExtensions/DynamicQueryExtensions.cs
@@ -36,14 +36,16 @@ public static IFilterOperator WithEach(this IFilterOperator query, I
public static IFilterOperator NotIn(this IQueryFilter query, params P[] values)
{
var exp = query as IFilterExpression;
-
- exp.LastOperation.AddGroupExpression(string.IsNullOrEmpty(exp.LastOperation.PropertyName) ? "" : "And",
+
+ exp.PrevOperation.AddGroupExpression(string.IsNullOrEmpty(exp.PrevOperation.PropertyName) ? "" : "And",
p => p.Where(exp.PropertyName)
._NotIn(values));
+
+ //ignore current expression because we need override and keep the previous expression
exp.PropertyName = null;
exp.Operator = null;
-
- return exp.LastOperation;
+ exp.PrevOperation.Operator = null;
+ return exp.PrevOperation;
}
///
/// Build a filter to check if current field value was present in given list
@@ -58,13 +60,15 @@ public static IFilterOperator In(this IQueryFilter query, params
var exp = query as IFilterExpression;
- exp.LastOperation.AddGroupExpression(string.IsNullOrEmpty(exp.LastOperation.PropertyName) ? "" : "And",
+ exp.PrevOperation.AddGroupExpression(string.IsNullOrEmpty(exp.PrevOperation.PropertyName) ? "" : "And",
p => p.Where(exp.PropertyName)
._In(values));
+
+ //ignore current expression because we need override and keep the previous expression
exp.PropertyName = null;
exp.Operator = null;
-
- return exp.LastOperation;
+ exp.PrevOperation.Operator = null;
+ return exp.PrevOperation;
}
private static IFilterOperator _In(this IQueryFilter query, P[] values)
@@ -75,7 +79,7 @@ private static IFilterOperator _In(this IQueryFilter query, P[] valu
nextQuery = (IQuery)(nextQuery as IQueryFilter)
.Equal(item)
.Or((query as IFilterExpression).PropertyName);
- }
+ }
(nextQuery as IQueryFilter).Equal(values.Last());
return nextQuery as IFilterOperator;
}
diff --git a/src/Azure.EntityServices.Queries/IQueryExpression.cs b/src/Azure.EntityServices.Queries/IQueryExpression.cs
index e8a2705..11a3482 100644
--- a/src/Azure.EntityServices.Queries/IQueryExpression.cs
+++ b/src/Azure.EntityServices.Queries/IQueryExpression.cs
@@ -13,6 +13,6 @@ public interface IFilterExpression : IFilterOperator, IQueryFilter, IQu
List> Group { get; }
public string GroupOperator { get; set; }
IFilterExpression NextOperation { get; set; }
- IFilterExpression LastOperation { get; set; }
+ IFilterExpression PrevOperation { get; set; }
}
}
\ No newline at end of file
diff --git a/tests/Azure.EntityServices.Tests/Azure.EntityServices.Tests.csproj b/tests/Azure.EntityServices.Tests/Azure.EntityServices.Tests.csproj
index f1e593a..d417de7 100644
--- a/tests/Azure.EntityServices.Tests/Azure.EntityServices.Tests.csproj
+++ b/tests/Azure.EntityServices.Tests/Azure.EntityServices.Tests.csproj
@@ -1,4 +1,4 @@
-
+
net6.0
@@ -15,7 +15,7 @@