Interface IDataService
Services on Kit.Data to create DataSources in Razor.
[PublicApi]
public interface IDataService
Remarks
Can also be used in external code such as Skins using Dependency Injection. New in v16.00
Methods
CombineLinks(params IDataSourceLinkable[])
Merge many links to usually attach to a new data source. Use this when you want to attach more than one source to a new DataSource.
IDataSourceLink CombineLinks(params IDataSourceLinkable[] sources)
Parameters
sourcesIDataSourceLinkable[]One or more sources. Make sure they specify different In names - usually using CreateLink(IDataSourceLinkable, NoParamOrder, string?, string?).
Returns
Remarks
Introduced in v21.04, previous API (rarely used) has not worked for a while.
CreateLink(IDataSourceLinkable, NoParamOrder, string?, string?)
Create a connection-link of a data source or stream. Mainly used for linking to a source with another name.
IDataSourceLink CreateLink(IDataSourceLinkable source, NoParamOrder npo = default, string? inName = null, string? outName = null)
Parameters
sourceIDataSourceLinkableThe source (stream or data source)
npoNoParamOrderinNamestringWhat In-Stream it should connect to. Optional, default is "Default"
outNamestringWhat Out-stream it should use from the source. Optional, default is "Default" (rarely changed).
Returns
Remarks
Introduced in v21.04, previous API (rarely used) has not worked for a while.
GetAppSource(NoParamOrder, object?, object?)
Get the App DataSource containing the App Data.
The Default stream of this source has the data the current user is allowed to see.
So public users won't get draft data.
[PublicApi]
IDataSource GetAppSource(NoParamOrder npo = default, object? parameters = null, object? options = null)
Parameters
npoNoParamOrderparametersobjectParameters to use - as anonymous object like
new { Count = 7, Filter = 3 }optionsobjectOptions how to build/construct the DataSource.
Returns
GetQuery(string?, NoParamOrder, IDataSourceLinkable?, object?)
Get a Query from the current App.
[PublicApi]
IDataSource? GetQuery(string? name = null, NoParamOrder npo = default, IDataSourceLinkable? attach = null, object? parameters = null)
Parameters
namestringName of the query
npoNoParamOrderattachIDataSourceLinkableAttach in-stream to the query (not yet implemented)
parametersobjectParameters to use - as anonymous object like
new { Count = 7, Filter = 3 }
Returns
Remarks
New 16.01
GetSource(NoParamOrder, string?, IDataSourceLinkable?, object?, object?, bool?)
Create a DataSource object using it's name. This is only meant for dynamically compiled DataSources which are part of the current App - a new feature in v15.10+. For any other DataSources, use the overload which specifies the type.
[PublicApi]
IDataSource GetSource(NoParamOrder npo = default, string? name = null, IDataSourceLinkable? attach = null, object? parameters = null, object? options = null, bool? debug = null)
Parameters
npoNoParamOrdernamestringThe name of the DataSource type, which matches the file name and class in the
/DataSources/folder.attachIDataSourceLinkableLink to one or more other DataSources / streams to attach upon creation.
parametersobjectParameters to use - as anonymous object like
new { Count = 7, Filter = 3 }optionsobjectOptions how to build/construct the DataSource.
debugbool?Determines if exceptions should be shown. Default is only for Developers.
Returns
Remarks
new v16.00
GetSource<T>(NoParamOrder, IDataSourceLinkable?, object?, object?)
Create a DataSource object using it's type. This is the new, preferred way to get DataSources in v15.06+.
[PublicApi]
T GetSource<T>(NoParamOrder npo = default, IDataSourceLinkable? attach = null, object? parameters = null, object? options = null) where T : IDataSource
Parameters
npoNoParamOrderattachIDataSourceLinkableLink to one or more other DataSources / streams to attach upon creation.
parametersobjectParameters to use - as anonymous object like
new { Count = 7, Filter = 3 }optionsobjectOptions how to build/construct the DataSource.
Returns
- T
Type Parameters
TThe type of DataSource, usually from ToSic.Eav.DataSources or ToSic.Sxc.DataSources
Remarks
new v16.00