Created
June 17, 2025 06:55
-
-
Save KayeeNL/0116dc5bdc2bc08437f479f6b685af7f to your computer and use it in GitHub Desktop.
Sitecore Content Hub CreateEntityScroller Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Stylelabs.M.Sdk.WebClient; | |
using Stylelabs.M.Base.Querying; | |
using Stylelabs.M.Framework.Essentials.LoadConfigurations; | |
using Microsoft.Extensions.Caching.Memory; | |
var mClient = new MClient("https://your-contenthub-url", "your-client-id", "your-client-secret"); | |
var memoryCache = new MemoryCache(new MemoryCacheOptions()); | |
var query = Query.CreateQuery(entities => | |
from e in entities | |
where e.DefinitionName == "Uxbee.M.DemoEntity" | |
select e | |
); | |
var scroller = mClient.Querying.CreateEntityScroller(query, TimeSpan.FromSeconds(30)); | |
var referenceEntities = new List<IEntity>(); | |
while (await scroller.MoveNextAsync()) | |
{ | |
var batch = scroller.Current.Items; | |
referenceEntities.AddRange(batch); | |
} | |
memoryCache.Set("ReferenceEntities", referenceEntities, TimeSpan.FromHours(1)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment