Guide Create Custom DataSources
There is a lot of information about DataSources, but some of it is outdated, and some of it is hard to understand. This guide will help you get started and find the right information.
Start with an Overview
Before you even start it's best to have an overview. The 2sxc 16 Dynamic DataSources Release Video is a good place to start.
Step 1: Experience Live Code
Before you read anything else in these docs, you must look at the live tutorials. This will help you understand what's actually going on. The remaining documentation assumes you have seen these tutorials.
🚀 first you must review the live samples in our Dynamic DataSources Tutorials
Step 2: Review your Understanding
Once you have seen the live code, you should have a basic idea of:
- What a Custom DataSource is
- What Data Streams are, and how they are provided using
ProvideOut
- How DataSources are made configurable using
[Configuration]
and how they read the configuration usingConfiguration.GetThis()
andConfiguration.GetThis<T>()
- Use in Razor/WebApi C# Code
- How code will create such a DataSource using
Kit.Data.GetSource
- How code can connect DataSources using
attach
- How code can pass in configuration using
parameters:
- How code will create such a DataSource using
- Use in Visual Query
- How DataSources appear in VisualQuery
- How they can be configured using the ContentType
Tip
The above list of things you should understand is important. Make sure you can say yes to each point mentioned above, otherwise go back and review the live tutorials.
Step 3: Learn the Big Picture
💡 You should read through the Big Picture of DataSources
Step 4: Create your first Dynamic DataSources
Now that you have seen the live tutorials, you should create a few Dynamic DataSources. You should not start with Compiled DataSources. They are much more difficult, and each failed try requires a rebuild, redeploy and restart of the website - with takes a long time.
Step 4: Deepen your Understanding
If you got this far and would like to go even deeper, this is what you probably need:
- how to provide data in different streams and different data types
- how to build entities with different property types and relationships as well as RawEntity objects
- advanced configuration possibilities
- use data from
In
streams, both theDefault
as well as other streams - error handling
Step 5: Create Compiled DataSources (optional)
Only do this if you really need to, because it's much more complex and requires a lot of knowledge about the internals of the EAV.
The guide stops here, but you can continue on Compiled DataSources.
Demo App and further links
History
- Introduced in 2sxc ca. 4 but with a difficult API
- API strongly enhanced and simplifield in 2sxc 09.13
- Another API rework ca. 2sxc 10.25 (but we're not exactly sure)
- Major breaking API changes and improvements in 2sxc 15
- Dynamic DataSources introduced in 2sxc 16