Class Shuffle
- Namespace
- ToSic.Eav.DataSources
- Assembly
- ToSic.Eav.DataSources.dll
The base class for all DataSources, especially custom DataSources. It must always be inherited. It provides a lot of core functionality to get configurations, ensure caching and more.
Important: in most cases you will inherit the CustomDataSource DataSource for custom data sources.
The Shuffle DataSource is part of the Standard EAV Data Sources. It will randomize the order of items which came in. This is common for components which show "3 random quotes" and similar scenarios.
How to use with the VisualQuery
When using the VisualQuery you can just drag it into your query. This is what it usually looks like:
The above example shows:
- a content-type filter limiting the items to type Company
- a shuffle which only passes on 3 random companies
Programming With The Shuffle DataSource
We recommend to use the VisualQuery where possible, as it's easier to understand and is identical for C# and JavaScript. It's also better because it separates data-retrieval from visualization.
Read also
Demo App and further links
You should find some examples in this demo App
History
- Introduced in EAV 4.x, 2sxc ?
API Documentation
[PublicApi]
[VisualQuery(NiceName = "Shuffle", UiHint = "Mix/randomize the order of items", Icon = "shuffle", Type = DataSourceType.Sort, NameId = "ToSic.Eav.DataSources.Shuffle, ToSic.Eav.DataSources", DynamicOut = false, In = new string[] { "Default*" }, ConfigurationType = "38e7822b-1049-4539-bb3f-f99949b1b1d1", HelpLink = "https://go.2sxc.org/DsShuffle")]
public sealed class Shuffle : DataSourceBase, IDataSource, IAppIdentity, IZoneIdentity, IAppIdentityLight, ICacheKey, ICacheExpiring, ITimestamped, IHasLog, IDataSourceLinkable
- Inheritance
-
objectServiceBaseShuffle
- Implements
- Inherited Members
Remarks
Had a major, breaking update in v15. Consult the guide to upgrade your custom data sources.
Properties
Take
Amount of items to take / return when shuffling.
Defaults to 0
meaning take-all.
[Configuration(Fallback = 0)]
public int Take { get; set; }