Table of Contents

Interface IDataService

Namespace
ToSic.Sxc.Services
Assembly
ToSic.Sxc.Apps.dll

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

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

sources IDataSourceLinkable[]

One or more sources. Make sure they specify different In names - usually using CreateLink(IDataSourceLinkable, NoParamOrder, string?, string?).

Returns

IDataSourceLink

Introduced in v21.04, previous API (rarely used) has not worked for a while.

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

source IDataSourceLinkable

The source (stream or data source)

npo NoParamOrder

see Convention: Named Parameters

inName string

What In-Stream it should connect to. Optional, default is "Default"

outName string

What Out-stream it should use from the source. Optional, default is "Default" (rarely changed).

Returns

IDataSourceLink

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

npo NoParamOrder

see Convention: Named Parameters

parameters object

Parameters to use - as anonymous object like new { Count = 7, Filter = 3 }

options object

Options how to build/construct the DataSource.

Returns

IDataSource

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

name string

Name of the query

npo NoParamOrder

see Convention: Named Parameters

attach IDataSourceLinkable

Attach in-stream to the query (not yet implemented)

parameters object

Parameters to use - as anonymous object like new { Count = 7, Filter = 3 }

Returns

IDataSource

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

npo NoParamOrder

see Convention: Named Parameters

name string

The name of the DataSource type, which matches the file name and class in the /DataSources/ folder.

attach IDataSourceLinkable

Link to one or more other DataSources / streams to attach upon creation.

parameters object

Parameters to use - as anonymous object like new { Count = 7, Filter = 3 }

options object

Options how to build/construct the DataSource.

debug bool?

Determines if exceptions should be shown. Default is only for Developers.

Returns

IDataSource

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

npo NoParamOrder

see Convention: Named Parameters

attach IDataSourceLinkable

Link to one or more other DataSources / streams to attach upon creation.

parameters object

Parameters to use - as anonymous object like new { Count = 7, Filter = 3 }

options object

Options how to build/construct the DataSource.

Returns

T

Type Parameters

T

The type of DataSource, usually from ToSic.Eav.DataSources or ToSic.Sxc.DataSources

Remarks

new v16.00