Skip to main content
Home  ›  Blog

Custom DataSource API - Provide

DataSources always provide data on an Out stream. The Provide method makes it very easy to do.

This is part of the new API for DataSources released in 2sxc 9.13.

How to use

In general, you need to

  • have a private method - usually called GetList() that would return a list of items, if it is called
  • use that GetList() to build a stream, which has a name - typically Default
  • attach that stream to the Out so that it's accessible

Here's a simple example of the constructor of the DnnFormAndList DataSource, which provides the default stream:

Using Provide in the Constructor

public DnnFormAndList()
{
    // Specify what out-streams this data-source provides. Usually just one, called "Default"
    Provide(GetList); // does everything

    // ...
}
private IEnumerable<Eav.Interfaces.IEntity> GetList() 
{
    // ...
}

This example ensures that the .Out["Default"] as well as the .List (which is a shorthand for .Out[Constants.DefaultStreamName].List) are mounted, ready to deliver.

More Docs and Advanced Use Cases

Of course you can do more :). To read about that, check out the wiki-documentation of the Provide helper

Love from Switzerland
Daniel


Daniel Mettler grew up in the jungles of Indonesia and is founder and CEO of 2sic internet solutions in Switzerland and Liechtenstein, an 20-head web specialist with over 800 DNN projects since 1999. He is also chief architect of 2sxc (see github), an open source module for creating attractive content and DNN Apps.

Read more posts by Daniel Mettler