It is now easy to create custom DataSources and distribute them with your Apps, thanks to Dynamic DataSources, which are just C# code files in your App folder.
TL;DR - Watch the Video
The samples in the video are in our live tutorials. This is what a lightweight DataSource can look like:
Background: What's a DataSource
Every Razor and WebApi in 2sxc works with data, often with the Content or Data objects. Internally the data is provided from DataSources and Queries (which are also DataSources).
Every DataSource has one or more Out-Streams providing data - such as a Paging DataSource, which provides all the items of the current page on the stream Default and paging information (page size, amounts of pages etc.) on the Paging stream.
DataSources can also have one or many In-Streams. The Paging DataSource will take a stream of data (eg. all the items in a blog) and split them into many pages.
2sxc comes with about 30 built-in DataSources, but there's always the need for more. For example, we have custom SharePoint DataSources which retrieve documents or search-results from SharePoint.
Previously: Compiled DataSources
Up until now all DataSources had to be developed and compiled into a DLL which was very sophisticated and could not be distributed with the App directly. This was fine for enterprise scenarios (eg. the SharePoint DataSource) but intimidating for developers who just wanted to provide some weather data in a DataSource.
New: Dynamic DataSources
The new DataSources:
- have a massively simplified API
- are just code files like MyDataSource.cs in the App folder
- are included when exporting/importing an App
- can be used in Razor, WebApis as well as VisualQueries
- have a lot of live tutorials to see them in action and use as inspiration
- have a lot of documentation!
Dynamic DataSources Live
We've created extensive docs and more than 25 samples in our live tutorial, which you should check out right away!
May the 4th be with you,