This is a 10-line super-simple example of a DataSource called Basic101
. It will only return a single item with the answer to the meaning of life 😉. Afterwards we'll explain in more detail what's happening.
-
-
⬇️ Result | Source ➡️
Error Showing Content - please login as admin for details.
Custom Dynamic DataSources - Lists
The previous example just returned one item/entity. But of course you can also return a list of items. This is the more common case. Our sample basically will just return data it generated, but your code will usually get data from elsewhere and provide it as a list.
Return a list of items numbered 1...5 with random Guid identifier.
-
-
⬇️ Result | Source ➡️
Error Showing Content - please login as admin for details.
Custom Dynamic DataSources - Configuration
Often you will need a DataSource that accepts some kind of parameters (configuration). The code must have [Configuration]
attributes on the properties that should be configurable. When calling GetSource(...)
use options: new { ... }
to set the values.
This simple example will get a DataSource from a file, and pass some configuration options. Specifically we'll give it the AmountOfItems
and FavoriteColor
.
-
-
⬇️ Result | Source ➡️
Error Showing Content - please login as admin for details.
Custom Dynamic DataSources - Process In-Data
DataSources be attached together. This means that you can create a DataSource which takes one or more DataSources as input.
This example has a DataSource which receives data from an <em>upstream</em> source. The upstream source is the list of all authors in this App. Our DataSource will then filter this list, and only keep the authors with an odd ID.
-
-
⬇️ Result | Source ➡️
Error Showing Content - please login as admin for details.
Multiple Lists/Streams
DataSources can have one or more streams.
The default stream is called Default
so you don't need to specify it. In the following example, we have a second stream called Settings
.
-
-
⬇️ Result | Source ➡️
Error Showing Content - please login as admin for details.
Get Data from Other DataSources
DataSources can also get other DataSources. For example, a DataSource could get data from the App directly to process them.
The Authors
DataSource demonstrates how to get all App data and then filter it using an inner EntityTypeFilter
DataSource.
-
-
⬇️ Result | Source ➡️
Error Showing Content - please login as admin for details.
#1 Dynamic DataSources Tutorial