I have a reusable content type called Event that has a field called EventRegion, this field is a content item selector to select a reusable content type called Region. As we know, in the database the EventRegion stores a JSON string of an array of the selected content item GUID's.
So the EventRegion field would contain data like this for example: [{"Identifier":"656eef94-63y1-4d2h-b0b5-05kdb4654342"}]
I want to do the following query to retrieve events that are in the region I selected:
var eventIds = (await executor.GetMappedResult<Entities.Event>(
new ContentItemQueryBuilder().ForContentType(Entities.Event.CONTENT_TYPE_NAME, config => config
.Where(where => where.WhereContains(nameof(Entities.Event.EventRegion), region.SystemFields.ContentItemGUID.ToString())) // improve this line
.Columns("ContentItemID")
),
options: new ContentQueryExecutionOptions { ForPreview = true },
cancellationToken: cancellationToken
))
.Select(e => e.SystemFields.ContentItemID)
.ToList();
but using the WhereContains and converting the GUID to a string isnt the best route. Anyone have any ideas on how I can improve that code? Maybe a different content retriever API would be better?
EDIT:
What I'm trying to accomplish is retrieving events that are in the selected region. This code is within a widget and the widget has a ContentItemSelector field called Region that allows the user to select 1 content item of type Region. I then need to automatically pull in the next 3 upcoming events for that selected region. Events have a field for choosing the Region content item it belongs in. I don't need to region data for the Event I am trying to improve my Where clause in the query but the way linked content items are stored in the database is via a JSON string of the content item GUID.
Environment
Xperience by Kentico version: 30.8.2
.NET version: 8