Class DataSource16
- Namespace
- Custom.DataSource
- Assembly
- ToSic.Sxc.dll
The Base Class for custom Dynamic DataSources in your App.
[PublicApi]
public abstract class DataSource16 : ServiceBase<DataSource16.MyServices>, IDataSource, IDataSourceLinkable, IAppIdentity, IZoneIdentity, IAppIdentityLight, ICacheKey, ICacheExpiring, ITimestamped, IHasLog
- Inheritance
-
objectServiceBaseDataSource16
- Implements
Constructors
DataSource16(MyServices, string)
Constructor with the option to provide a log name.
protected DataSource16(DataSource16.MyServices services, string logName = null)
Parameters
services
DataSource16.MyServicesAll the needed services - see Convention: MyServices
logName
stringOptional name for logging such as
My.JsonDS
Properties
AppId
The app id as used internally
public int AppId { get; }
Property Value
- int
The App ID this thing belongs to
Configuration
The configuration system of this data source. Keeps track of all values which the data source will need, and manages the LookUp engine which provides these values.
public IDataSourceConfiguration Configuration { get; }
Property Value
Error
Special helper to generate error-streams.
DataSources should never throw
exceptions but instead return a stream containing the error information.
public DataSourceErrorHelper Error { get; }
Property Value
Kit
A simplified (light) Kit containing a bunch of helpers.
public ServiceKitLight16 Kit { get; }
Property Value
Remarks
This Kit has fewer APIs than in the typical Razor Kits, because many of the Razor APIs require a Razor context.
Log
The logger for the current Razor / WebApi which allows you to add logs to Insights.
public ICodeLog Log { get; }
Property Value
ZoneId
ID of the zone (EAV Tenant)
public int ZoneId { get; }
Property Value
- int
The zone ID this thing belongs to
Methods
GetDefault()
Optional method to provide default data. You can override this, or use one or more ProvideOut(Func<object>, NoParamOrder, string, Func<DataFactoryOptions>) in your constructor.
protected virtual IEnumerable<IRawEntity> GetDefault()
Returns
- IEnumerable<IRawEntity>
ProvideOut(Func<object>, NoParamOrder, string, Func<DataFactoryOptions>)
Provide out-data on this data source. Typically called in the constructor.
You can call this multiple times, providing different names.
protected void ProvideOut(Func<object> getList, NoParamOrder noParamOrder = default, string name = "Default", Func<DataFactoryOptions> options = null)
Parameters
getList
Func<object>noParamOrder
NoParamOrdername
stringoptions
Func<DataFactoryOptions>
TryGetIn(string)
public IImmutableList<IEntity> TryGetIn(string name = "Default")
Parameters
name
string
Returns
TryGetOut(string)
public IImmutableList<IEntity> TryGetOut(string name = "Default")
Parameters
name
string