From 4b97427aecf34de2c0ccd9346fc9fbbeecde92d3 Mon Sep 17 00:00:00 2001 From: vivet Date: Sun, 28 Dec 2025 11:14:22 +0100 Subject: [PATCH 1/2] Upgraded to .NET 10 --- .github/workflows/build-and-deploy.yml | 4 +- .../CriteriaBuilderTest.cs | 3 +- .../CriteriaExpressionTest.cs | 49 ++++---- .../Extensions/QueryableExtensionsTest.cs | 2 +- .../Properties/DoNotParallelize.cs | 3 + .../Tests.DynamicExpression.csproj | 8 +- DynamicExpression/CriteriaExpression.cs | 52 ++++---- DynamicExpression/DynamicExpression.csproj | 12 +- DynamicExpression/Entities/Criteria.cs | 112 +++++------------- 9 files changed, 101 insertions(+), 144 deletions(-) create mode 100644 .tests/Tests.DynamicExpression/Properties/DoNotParallelize.cs diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 7e594cc..86123a7 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -8,7 +8,7 @@ on: - master env: APP_NAME: DynamicExpression - VERSION: 9.0.3 + VERSION: 10.0.0 NUGET_HOST: https://api.nuget.org/v3/index.json NUGET_APIKEY: ${{ secrets.NUGET_APIKEY }} jobs: @@ -25,7 +25,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-dotnet@v3 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Build and Test shell: pwsh diff --git a/.tests/Tests.DynamicExpression/CriteriaBuilderTest.cs b/.tests/Tests.DynamicExpression/CriteriaBuilderTest.cs index 40637ab..8cedb02 100644 --- a/.tests/Tests.DynamicExpression/CriteriaBuilderTest.cs +++ b/.tests/Tests.DynamicExpression/CriteriaBuilderTest.cs @@ -1,10 +1,11 @@ using System; using System.Collections.Generic; +using DynamicExpression; using DynamicExpression.Enums; using Microsoft.VisualStudio.TestTools.UnitTesting; using NetTopologySuite.Geometries; -namespace DynamicExpression.Test; +namespace Tests.DynamicExpression; [TestClass] public class CriteriaBuilderTest diff --git a/.tests/Tests.DynamicExpression/CriteriaExpressionTest.cs b/.tests/Tests.DynamicExpression/CriteriaExpressionTest.cs index 436fd22..69f7d69 100644 --- a/.tests/Tests.DynamicExpression/CriteriaExpressionTest.cs +++ b/.tests/Tests.DynamicExpression/CriteriaExpressionTest.cs @@ -1,8 +1,9 @@ using System.Linq; +using DynamicExpression; using DynamicExpression.Enums; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace DynamicExpression.Test; +namespace Tests.DynamicExpression; [TestClass] public class CriteriaExpressionTest @@ -17,7 +18,7 @@ public void ConstructorWhenEqualTest() Assert.IsNotNull(criteria); Assert.AreEqual("name", criteria.Property); Assert.AreEqual("value", criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.Equal, criteria.OperationType); } @@ -32,7 +33,7 @@ public void ConstructorWhenStartsWithTest() Assert.IsNotNull(criteria); Assert.AreEqual("name", criteria.Property); Assert.AreEqual("value", criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.StartsWith, criteria.OperationType); } @@ -47,7 +48,7 @@ public void ConstructorWhenEndWithTest() Assert.IsNotNull(criteria); Assert.AreEqual("name", criteria.Property); Assert.AreEqual("value", criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.EndsWith, criteria.OperationType); } @@ -62,7 +63,7 @@ public void ConstructorWhenGreaterThanTest() Assert.IsNotNull(criteria); Assert.AreEqual("Age", criteria.Property); Assert.AreEqual(1, criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.GreaterThan, criteria.OperationType); } @@ -77,7 +78,7 @@ public void ConstructorWhenGreaterThanOrEqualTest() Assert.IsNotNull(criteria); Assert.AreEqual("Age", criteria.Property); Assert.AreEqual(1, criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.GreaterThanOrEqual, criteria.OperationType); } @@ -92,7 +93,7 @@ public void ConstructorWhenLessThanTest() Assert.IsNotNull(criteria); Assert.AreEqual("Age", criteria.Property); Assert.AreEqual(1, criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.LessThan, criteria.OperationType); } @@ -107,7 +108,7 @@ public void ConstructorWhenLessThanOrEqualTest() Assert.IsNotNull(criteria); Assert.AreEqual("Age", criteria.Property); Assert.AreEqual(1, criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.LessThanOrEqual, criteria.OperationType); } @@ -136,8 +137,8 @@ public void ConstructorWhenIsNullTest() var criteria = expression.Criterias.FirstOrDefault(); Assert.IsNotNull(criteria); Assert.AreEqual("Name", criteria.Property); - Assert.AreEqual(null, criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.IsNull, criteria.OperationType); } @@ -151,8 +152,8 @@ public void ConstructorWhenIsNotNullTest() var criteria = expression.Criterias.FirstOrDefault(); Assert.IsNotNull(criteria); Assert.AreEqual("Name", criteria.Property); - Assert.AreEqual(null, criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.IsNotNull, criteria.OperationType); } @@ -166,8 +167,8 @@ public void ConstructorWhenIsEmptyTest() var criteria = expression.Criterias.FirstOrDefault(); Assert.IsNotNull(criteria); Assert.AreEqual("Name", criteria.Property); - Assert.AreEqual(null, criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.IsEmpty, criteria.OperationType); } @@ -181,8 +182,8 @@ public void ConstructorWhenIsNotEmptyTest() var criteria = expression.Criterias.FirstOrDefault(); Assert.IsNotNull(criteria); Assert.AreEqual("Name", criteria.Property); - Assert.AreEqual(null, criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.IsNotEmpty, criteria.OperationType); } @@ -196,8 +197,8 @@ public void ConstructorWhenIsNullOrWhiteSpaceTest() var criteria = expression.Criterias.FirstOrDefault(); Assert.IsNotNull(criteria); Assert.AreEqual("Name", criteria.Property); - Assert.AreEqual(null, criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.IsNullOrWhiteSpace, criteria.OperationType); } @@ -211,8 +212,8 @@ public void ConstructorWhenIsNotNullOrWhiteSpaceTest() var criteria = expression.Criterias.FirstOrDefault(); Assert.IsNotNull(criteria); Assert.AreEqual("Name", criteria.Property); - Assert.AreEqual(null, criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.IsNotNullOrWhiteSpace, criteria.OperationType); } @@ -228,7 +229,7 @@ public void ConstructorWhenInTest() Assert.IsNotNull(criteria); Assert.AreEqual("Name", criteria.Property); Assert.AreEqual(array, criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.In, criteria.OperationType); } @@ -244,7 +245,7 @@ public void ConstructorWhenNotInTest() Assert.IsNotNull(criteria); Assert.AreEqual("Name", criteria.Property); Assert.AreEqual(array, criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.NotIn, criteria.OperationType); } @@ -259,7 +260,7 @@ public void ConstructorWhenContainsTest() Assert.IsNotNull(criteria); Assert.AreEqual("Name", criteria.Property); Assert.AreEqual("value", criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.Contains, criteria.OperationType); } @@ -274,7 +275,7 @@ public void ConstructorWhenNotContainsTest() Assert.IsNotNull(criteria); Assert.AreEqual("Name", criteria.Property); Assert.AreEqual("value", criteria.Value); - Assert.AreEqual(null, criteria.Value2); + Assert.IsNull(criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.NotContains, criteria.OperationType); } diff --git a/.tests/Tests.DynamicExpression/Extensions/QueryableExtensionsTest.cs b/.tests/Tests.DynamicExpression/Extensions/QueryableExtensionsTest.cs index e2814c8..381bdf4 100644 --- a/.tests/Tests.DynamicExpression/Extensions/QueryableExtensionsTest.cs +++ b/.tests/Tests.DynamicExpression/Extensions/QueryableExtensionsTest.cs @@ -6,7 +6,7 @@ using DynamicExpression.Extensions; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace DynamicExpression.Test.Extensions; +namespace Tests.DynamicExpression.Extensions; [TestClass] public class QueryableExtensionsTest diff --git a/.tests/Tests.DynamicExpression/Properties/DoNotParallelize.cs b/.tests/Tests.DynamicExpression/Properties/DoNotParallelize.cs new file mode 100644 index 0000000..6a07666 --- /dev/null +++ b/.tests/Tests.DynamicExpression/Properties/DoNotParallelize.cs @@ -0,0 +1,3 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[assembly: DoNotParallelize] \ No newline at end of file diff --git a/.tests/Tests.DynamicExpression/Tests.DynamicExpression.csproj b/.tests/Tests.DynamicExpression/Tests.DynamicExpression.csproj index c402aee..81ca19f 100644 --- a/.tests/Tests.DynamicExpression/Tests.DynamicExpression.csproj +++ b/.tests/Tests.DynamicExpression/Tests.DynamicExpression.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 true @@ -9,9 +9,9 @@ - - - + + + diff --git a/DynamicExpression/CriteriaExpression.cs b/DynamicExpression/CriteriaExpression.cs index 433f132..8077159 100644 --- a/DynamicExpression/CriteriaExpression.cs +++ b/DynamicExpression/CriteriaExpression.cs @@ -28,7 +28,7 @@ public virtual void Equal(string property, TType value, LogicalType logic if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.Equal, value, default, logicalType); + this.By(property, OperationType.Equal, value, null, logicalType); } /// @@ -43,7 +43,7 @@ public virtual void NotEqual(string property, TType value, LogicalType lo if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.NotEqual, value, default, logicalType); + this.By(property, OperationType.NotEqual, value, null, logicalType); } /// @@ -58,7 +58,7 @@ public virtual void StartsWith(string property, TType value, LogicalType if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.StartsWith, value, default, logicalType); + this.By(property, OperationType.StartsWith, value, null, logicalType); } /// @@ -73,7 +73,7 @@ public virtual void EndsWith(string property, TType value, LogicalType lo if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.EndsWith, value, default, logicalType); + this.By(property, OperationType.EndsWith, value, null, logicalType); } /// @@ -88,7 +88,7 @@ public virtual void GreaterThan(string property, TType value, LogicalType if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.GreaterThan, value, default, logicalType); + this.By(property, OperationType.GreaterThan, value, null, logicalType); } /// @@ -103,7 +103,7 @@ public virtual void GreaterThanOrEqual(string property, TType value, Logi if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.GreaterThanOrEqual, value, default, logicalType); + this.By(property, OperationType.GreaterThanOrEqual, value, null, logicalType); } /// @@ -118,7 +118,7 @@ public virtual void LessThan(string property, TType value, LogicalType lo if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.LessThan, value, default, logicalType); + this.By(property, OperationType.LessThan, value, null, logicalType); } /// @@ -133,7 +133,7 @@ public virtual void LessThanOrEqual(string property, TType value, Logical if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.LessThanOrEqual, value, default, logicalType); + this.By(property, OperationType.LessThanOrEqual, value, null, logicalType); } /// @@ -163,7 +163,7 @@ public virtual void IsNull(string property, LogicalType logicalType = Log if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.IsNull, default, default, logicalType); + this.By(property, OperationType.IsNull, default, null, logicalType); } /// @@ -177,7 +177,7 @@ public virtual void IsNotNull(string property, LogicalType logicalType = if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.IsNotNull, default, default, logicalType); + this.By(property, OperationType.IsNotNull, default, null, logicalType); } /// @@ -191,7 +191,7 @@ public virtual void IsEmpty(string property, LogicalType logicalType = Lo if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.IsEmpty, default, default, logicalType); + this.By(property, OperationType.IsEmpty, default, null, logicalType); } /// @@ -205,7 +205,7 @@ public virtual void IsNotEmpty(string property, LogicalType logicalType = if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.IsNotEmpty, default, default, logicalType); + this.By(property, OperationType.IsNotEmpty, default, null, logicalType); } /// @@ -219,7 +219,7 @@ public virtual void IsNullOrWhiteSpace(string property, LogicalType logic if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.IsNullOrWhiteSpace, default, default, logicalType); + this.By(property, OperationType.IsNullOrWhiteSpace, default, null, logicalType); } /// @@ -233,7 +233,7 @@ public virtual void IsNotNullOrWhiteSpace(string property, LogicalType lo if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.IsNotNullOrWhiteSpace, default, default, logicalType); + this.By(property, OperationType.IsNotNullOrWhiteSpace, default, null, logicalType); } /// @@ -248,7 +248,7 @@ public virtual void In(string property, TType value, LogicalType logicalT if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.In, value, default, logicalType); + this.By(property, OperationType.In, value, null, logicalType); } /// @@ -263,7 +263,7 @@ public virtual void NotIn(string property, TType value, LogicalType logic if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.NotIn, value, default, logicalType); + this.By(property, OperationType.NotIn, value, null, logicalType); } /// @@ -278,7 +278,7 @@ public virtual void Contains(string property, TType value, LogicalType lo if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.Contains, value, default, logicalType); + this.By(property, OperationType.Contains, value, null, logicalType); } /// @@ -293,7 +293,7 @@ public virtual void NotContains(string property, TType value, LogicalType if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.NotContains, value, default, logicalType); + this.By(property, OperationType.NotContains, value, null, logicalType); } /// @@ -308,7 +308,7 @@ public virtual void Covers(string property, TType value, LogicalType logi if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.Covers, value, default, logicalType); + this.By(property, OperationType.Covers, value, null, logicalType); } /// @@ -323,7 +323,7 @@ public virtual void Crosses(string property, TType value, LogicalType log if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.Crosses, value, default, logicalType); + this.By(property, OperationType.Crosses, value, null, logicalType); } /// @@ -338,7 +338,7 @@ public virtual void Touches(string property, TType value, LogicalType log if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.Touches, value, default, logicalType); + this.By(property, OperationType.Touches, value, null, logicalType); } /// @@ -353,7 +353,7 @@ public virtual void Overlaps(string property, TType value, LogicalType lo if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.Overlaps, value, default, logicalType); + this.By(property, OperationType.Overlaps, value, null, logicalType); } /// @@ -368,7 +368,7 @@ public virtual void CoveredBy(string property, TType value, LogicalType l if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.CoveredBy, value, default, logicalType); + this.By(property, OperationType.CoveredBy, value, null, logicalType); } /// @@ -383,7 +383,7 @@ public virtual void Disjoint(string property, TType value, LogicalType lo if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.Disjoint, value, default, logicalType); + this.By(property, OperationType.Disjoint, value, null, logicalType); } /// @@ -398,7 +398,7 @@ public virtual void Intersects(string property, TType value, LogicalType if (property == null) throw new ArgumentNullException(nameof(property)); - this.By(property, OperationType.Intersects, value, default, logicalType); + this.By(property, OperationType.Intersects, value, null, logicalType); } /// @@ -434,7 +434,7 @@ public virtual void IsWithinDistance(string property, TType value, double this.By(property, OperationType.IsWithinDistance, value, distance, logicalType); } - private void By(string property, OperationType operationType, TType value, object value2 = default, LogicalType logicalType = LogicalType.And) + private void By(string property, OperationType operationType, TType value, object value2 = null, LogicalType logicalType = LogicalType.And) { if (property == null) throw new ArgumentNullException(nameof(property)); diff --git a/DynamicExpression/DynamicExpression.csproj b/DynamicExpression/DynamicExpression.csproj index f0e8302..84e690b 100644 --- a/DynamicExpression/DynamicExpression.csproj +++ b/DynamicExpression/DynamicExpression.csproj @@ -1,11 +1,11 @@  - net9.0 + net10.0 true AnyCPU - 9.0.3.0 - 9.0.3.0 - 9.0.3.0 + 10.0.0.0 + 10.0.0.0 + 10.0.0.0 latest Michael Vivet Dynamic Expression @@ -15,7 +15,7 @@ Lampda, Expression, Linq, Dynamic, Criteria, Query, Paging, Pagination, Sort, Sorting README.md - - Moved CI/CD to GitHub Actions. + - Upgraded to .NET 10. https://raw.githubusercontent.com/vivet/DynamicExpression/master/LICENSE LICENSE @@ -49,6 +49,6 @@ - + diff --git a/DynamicExpression/Entities/Criteria.cs b/DynamicExpression/Entities/Criteria.cs index fdd6f73..6001b88 100644 --- a/DynamicExpression/Entities/Criteria.cs +++ b/DynamicExpression/Entities/Criteria.cs @@ -98,86 +98,38 @@ private IEnumerable GetSupportedOperationTypes(Type type) ? "Enum" : operationTypes.FirstOrDefault(x => x.Value.Any(y => y.Name == type.Name)).Key; - switch (operationType) + return operationType switch { - case "Text": - return - [ - OperationType.Equal, - OperationType.NotEqual, - OperationType.StartsWith, - OperationType.EndsWith, - OperationType.IsEmpty, - OperationType.IsNotEmpty, - OperationType.IsNull, - OperationType.IsNotNull, - OperationType.IsNullOrWhiteSpace, - OperationType.IsNotNullOrWhiteSpace, - OperationType.IsEmpty, - OperationType.IsNotEmpty, - OperationType.In, - OperationType.NotIn, - OperationType.Contains, - OperationType.NotContains - ]; - - case "Date": - case "Number": - return - [ - OperationType.Equal, - OperationType.NotEqual, - OperationType.GreaterThan, - OperationType.GreaterThanOrEqual, - OperationType.LessThan, - OperationType.LessThanOrEqual, - OperationType.Between - ]; - - case "Boolean": - case "Guid": - return - [ - OperationType.Equal, - OperationType.NotEqual - ]; - - case "Enum": - return - [ - OperationType.Equal, - OperationType.NotEqual, - OperationType.In, - OperationType.NotIn, - OperationType.Contains, - OperationType.NotContains - ]; - - case "Nullable": - return new[] - { - OperationType.IsNull, - OperationType.IsNotNull - } - .Union(this.GetSupportedOperationTypes(Nullable.GetUnderlyingType(type))) - .Distinct(); - - case "Spatial": - return - [ - OperationType.Covers, - OperationType.Crosses, - OperationType.Touches, - OperationType.Overlaps, - OperationType.CoveredBy, - OperationType.Disjoint, - OperationType.Intersects, - OperationType.Within, - OperationType.IsWithinDistance - ]; - - default: - throw new ArgumentOutOfRangeException(nameof(type)); - } + "Text" => + [ + OperationType.Equal, OperationType.NotEqual, OperationType.StartsWith, OperationType.EndsWith, + OperationType.IsEmpty, OperationType.IsNotEmpty, OperationType.IsNull, OperationType.IsNotNull, + OperationType.IsNullOrWhiteSpace, OperationType.IsNotNullOrWhiteSpace, OperationType.IsEmpty, + OperationType.IsNotEmpty, OperationType.In, OperationType.NotIn, OperationType.Contains, + OperationType.NotContains + ], + "Date" or "Number" => + [ + OperationType.Equal, OperationType.NotEqual, OperationType.GreaterThan, + OperationType.GreaterThanOrEqual, OperationType.LessThan, OperationType.LessThanOrEqual, + OperationType.Between + ], + "Boolean" or "Guid" => [OperationType.Equal, OperationType.NotEqual], + "Enum" => + [ + OperationType.Equal, OperationType.NotEqual, OperationType.In, OperationType.NotIn, + OperationType.Contains, OperationType.NotContains + ], + "Nullable" => new[] { OperationType.IsNull, OperationType.IsNotNull } + .Union(this.GetSupportedOperationTypes(Nullable.GetUnderlyingType(type))) + .Distinct(), + "Spatial" => + [ + OperationType.Covers, OperationType.Crosses, OperationType.Touches, OperationType.Overlaps, + OperationType.CoveredBy, OperationType.Disjoint, OperationType.Intersects, OperationType.Within, + OperationType.IsWithinDistance + ], + _ => throw new ArgumentOutOfRangeException(nameof(type)) + }; } } \ No newline at end of file From e08d5b5478e890d53c2a9f31dad058adfd407b28 Mon Sep 17 00:00:00 2001 From: vivet Date: Sun, 28 Dec 2025 11:17:40 +0100 Subject: [PATCH 2/2] Fixed tests --- .tests/Tests.DynamicExpression/CriteriaBuilderTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tests/Tests.DynamicExpression/CriteriaBuilderTest.cs b/.tests/Tests.DynamicExpression/CriteriaBuilderTest.cs index 8cedb02..86077a9 100644 --- a/.tests/Tests.DynamicExpression/CriteriaBuilderTest.cs +++ b/.tests/Tests.DynamicExpression/CriteriaBuilderTest.cs @@ -394,7 +394,7 @@ public void BuildWhenInAndArrayEnumTest() Assert.IsNotNull(expression); Assert.IsNotNull(expression.Compile()); - Assert.AreEqual("value(DynamicExpression.Test.CriteriaBuilderTest+FlagsEnum[]).Contains(x.Flags)", expression.Body.ToString()); + Assert.AreEqual("value(Tests.DynamicExpression.CriteriaBuilderTest+FlagsEnum[]).Contains(x.Flags)", expression.Body.ToString()); } [TestMethod]