From 96721d22edbe48c2d978c77948da5d8931fbae03 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Fri, 15 Nov 2024 18:36:51 +0100 Subject: [PATCH] Add collation. --- .../Directory.Build.props | 2 +- .../ContentQueryTests.cs | 20 +++++++++++++++++++ .../Squidex.ClientLibrary/ContentQuery.cs | 6 ++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/csharp/Squidex.ClientLibrary/Directory.Build.props b/csharp/Squidex.ClientLibrary/Directory.Build.props index 0a25beb..d7d7485 100644 --- a/csharp/Squidex.ClientLibrary/Directory.Build.props +++ b/csharp/Squidex.ClientLibrary/Directory.Build.props @@ -15,7 +15,7 @@ Squidex HeadlessCMS true snupkg - 20.0.0 + 20.1.0 diff --git a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary.Tests/ContentQueryTests.cs b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary.Tests/ContentQueryTests.cs index 0b6472b..e0061d5 100644 --- a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary.Tests/ContentQueryTests.cs +++ b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary.Tests/ContentQueryTests.cs @@ -81,6 +81,26 @@ public void ContentQuery_with_search_and_filter() Assert.Equal("?$filter=my-filter&$search=\"my-search\"", query); } + [Fact] + public void ContentQuery_with_random() + { + var query = new ContentQuery { Random = 42 } + .ToQuery(true, options) + .ToString(); + + Assert.Equal("?random=42", query); + } + + [Fact] + public void ContentQuery_with_collation() + { + var query = new ContentQuery { Collation = "tr" } + .ToQuery(true, options) + .ToString(); + + Assert.Equal("?collation=tr", query); + } + [Fact] public void ContentQuery_with_ids() { diff --git a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentQuery.cs b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentQuery.cs index 361809b..5b15d86 100644 --- a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentQuery.cs +++ b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentQuery.cs @@ -90,6 +90,11 @@ public class ContentQuery /// public string? Search { get; set; } + /// + /// The locale that is used to compare strings. + /// + public string? Collation { get; set; } + /// /// Pick a random number of elements from the result set. /// @@ -103,6 +108,7 @@ internal Query ToQuery(bool supportsSearch, SquidexOptions options) q.Append("$top", Top); q.Append("$orderby", OrderBy); q.Append("$filter", Filter); + q.Append("collation", Collation); q.Append("random", Random); q.AppendMany("ids", Ids);