From 47dd57fb888a59ca1e7804c15a5a963ccf42f462 Mon Sep 17 00:00:00 2001 From: Joshua Folkerts <74155642+JoshuaFolkerts@users.noreply.github.com> Date: Sun, 17 Mar 2024 12:10:11 -0500 Subject: [PATCH] Adding facet selector for collections Adding facets selector based on how the facets are setup. Allows facets to be selected based on type query.Facet(x=>x.Categories, c=>c.GuidValue) --- .../Api/Querying/TypeQueryBuilder.cs | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/APIs/src/EpiServer.ContentGraph/Api/Querying/TypeQueryBuilder.cs b/APIs/src/EpiServer.ContentGraph/Api/Querying/TypeQueryBuilder.cs index 53db3d8e..c27e7e1a 100644 --- a/APIs/src/EpiServer.ContentGraph/Api/Querying/TypeQueryBuilder.cs +++ b/APIs/src/EpiServer.ContentGraph/Api/Querying/TypeQueryBuilder.cs @@ -178,6 +178,85 @@ public TypeQueryBuilder Facet(string propertyName) $"{graphObject.Facets} {facet}"; return this; } + /// + /// Get facet by field in a nested object + /// + /// + /// + /// + /// + public TypeQueryBuilder Facet(Expression>> fieldSelector, Expression> propertySelector) + { + fieldSelector.ValidateNotNullArgument("fieldSelector"); + propertySelector.ValidateNotNullArgument("propertySelector"); + + Facet($"{fieldSelector.GetFieldPath()}.{propertySelector.GetFieldPath()}"); + return this; + } + + /// + /// Get facet by field in a nested object + /// + /// + /// + /// + /// + public TypeQueryBuilder Facet(Expression>> fieldSelector, Expression> propertySelector) + { + fieldSelector.ValidateNotNullArgument("fieldSelector"); + propertySelector.ValidateNotNullArgument("propertySelector"); + + Facet($"{fieldSelector.GetFieldPath()}.{propertySelector.GetFieldPath()}"); + return this; + } + + /// + /// Get facet by field in a nested object + /// + /// + /// + /// + /// + public TypeQueryBuilder Facet(Expression>> fieldSelector, Expression> propertySelector) + { + fieldSelector.ValidateNotNullArgument("fieldSelector"); + propertySelector.ValidateNotNullArgument("propertySelector"); + + Facet($"{fieldSelector.GetFieldPath()}.{propertySelector.GetFieldPath()}"); + return this; + } + + /// + /// Get facet by field in a nested object + /// + /// + /// + /// + /// + public TypeQueryBuilder Facet(Expression>> fieldSelector, Expression> propertySelector) + { + fieldSelector.ValidateNotNullArgument("fieldSelector"); + propertySelector.ValidateNotNullArgument("propertySelector"); + + Facet($"{fieldSelector.GetFieldPath()}.{propertySelector.GetFieldPath()}"); + return this; + } + + /// + /// Get facet by field in a nested object + /// + /// + /// + /// + /// + public TypeQueryBuilder Facet(Expression>> fieldSelector, Expression> propertySelector) + { + fieldSelector.ValidateNotNullArgument("fieldSelector"); + propertySelector.ValidateNotNullArgument("propertySelector"); + + Facet($"{fieldSelector.GetFieldPath()}.{propertySelector.GetFieldPath()}"); + return this; + } public TypeQueryBuilder Total(bool? isAll = null) { if (!isAll.HasValue)