Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KayeeNL/0116dc5bdc2bc08437f479f6b685af7f to your computer and use it in GitHub Desktop.
Save KayeeNL/0116dc5bdc2bc08437f479f6b685af7f to your computer and use it in GitHub Desktop.
Sitecore Content Hub CreateEntityScroller Example
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