Fork me on GitHub
2sxc 9.5 for DNN 7 to 9
Website Builder, Content Manager, App-System: open-source and amazing

List of all Data Sources

Introduced in Version 05.00.00

This is a list of all data sources available in 2SexyContent. To understand how to use these, read the related documentation.

Sample Code

This is just the brief documentation. To see sample code for each data source, install the data-demo-app

Here just a brief sample what it's about

@using ToSic.Eav.DataSources

<div class="BasicContentWithPreview sc-element">

       @Content.Toolbar

       <h1><span>@Content.Title</span></h1>

       @{

             // A source which can filter by Content-Type (EntityType)

             var allAuthors = CreateSource<EntityTypeFilter>();

             allAuthors.TypeName = "Author";

       }     

       <p>

             This just gets all authors from the DB and shows them.

       </p>

       <ul>

             @foreach (var dict in allAuthors.List)

             {

                    var author = AsDynamic(dict.Value);

                    <li>@author.FullName</li>

             }

       </ul>

</div>

DataSource: DataTableDataSource (new in 6.0.6)

  • Purpose: translate any existing DataTable into an entity-stream - can be used for XML, RSS, File-List or anything you want.
  • Supports Tokens for configuration
  • In: not necessary / not used

DataSource: EntityTypeFilter

  • Purpose: This data source retrieves all data of one type from the cache (or upsteam data source). It's like accessing a table of one type. 
  • Support Tokens in the input
  • In: default in-stream
    var newPipeline = CreateSource<EntityTypeFilter>(); // use default stream, cache
    or
    var newPipeline = CreateSource<EntityTypeFilter>(upStreamSource); // use another stream, for example another filter
  • Out: default out-stream (.List)

Parameters

  1. TypeName - the string-name of the type 
    1. static string name "Author" 
    2. string of the internal GUID of this type
    3. Token like "[QueryString:Type]" or "[AppSettings:Type]"

DataSource: ValueFilter

  • Purpose: Filter to only the entities which have a specific value.
  • Support Tokens in the input    
  • Only filters one attribute/value pair. To filter multiple attributes/values (like CompanyId = 27 AND LastName="Mettler") just chain multiple filters together
  • In: default in-stream
    var newPipeline = CreateSource<ValueFilter>(); // use default stream, cache
    or
    var newPipeline = CreateSource<ValueFilter>(upStreamSource); // use another stream, for example another filter
  • Out: default out-stream (.List)

Parameters

  1. Attribute - the property which is checked
    1. String like "FirstName"
    2. Special attribute like "EntityId" or "EntityTitle"
    3. or Token like "[QueryString:Filter1]
  2. Value    
    1. String like "Daniel
    2. Boolean (as String) like "True" (case sensitive
    3. Date (as String)
    4. Token like "[QueryString:App]"

DataSource: EntityIdFilter

  • Purpose: Only deliver one or more Entities based on the ID
  • Supports Tokens in the input
  • In: default in-stream
    var newPipeline = CreateSource<EntityIdFilter>(); // use default stream, cache
    or
    var newPipeline = CreateSource<EntityIdFilter>(upStreamSource); // use another stream, for example another filter
  • Out: default out-stream (.List)

Parameters

  1. EntityIds
    1. string with one or more (comma separated) IDs - like "27" or "27,402,5030,14"
    2. Token like "[QueryString:Ids]"

DataSource: SqlDataSource (new in 6.0.6)

  • Purpose: Retrieve SQL Data and provide the results as entities to the pipeline
  • Supports Tokens in the Input
  • In: no in used, as the data does not arrive as entities
  • Out: default out-stream (.List)

Parameters

  1. ConnectionStringName - the name used in the web.config, usually SiteSqlServer
  2. or ConnectionString (a normal SQL connection string)
  3. SelectCommand - a SQL select like "Select FileId as EntityId, FileName as EntityTitle From Files"
    Will need a field EntityId and EntityTitle to map to the entities...
  4. ...or you can set .TitleField to something else like "FileName"
  5. ...and/or you can set .EntityIdField to something else, like "FileId"
  6. Configuration[] is a collection of parameters, like
    1. .Configuration.Add("@PortalId", Dnn.Portal.PortalId.ToString());

Discover the demos here and try the App yourself from here.

DataSource: ValueSort

  • Purpose: Sort by one or more values
  • Supports Tokens in the input
  • In: default in-stream
    var newPipeline = CreateSource<ValueSort>(); // use default stream, cache
    or
    var newPipeline = CreateSource<ValueSort>(upStreamSource); // use another stream, for example another filter
  • Out: default out-stream (.List)

Parameters

  1. Attributes - one or more attributes to sort along
    1. String like "FullName" or "CompanyId,LastName,FirstName"
    2. Tokens like "[QueryString:OrderBy]"
  2. Directions - ascending / descending - understands "a", "asc", "d", "desc", "0", "1", ">", "<" (actually: d, desc, 0, > all sort descending, everything else is ascending)
    1. string like "asc", "asc,asc" "d,a,d"
    2. Tokens like "[QueryString:SortDirection]"

Special Notes

Other Filters

The following Filters are a bit unusual and only needed in special cases. They are provided as part of the system but not documented further here:

  1. Attribute Filter - strips entities of attributes. This is used before serializing to JSON or XML to prevent unwanted attributes from being sent over the wire
  2. PassThrough - just an empty pipeline-part that does nothing. Mainly for test purposes
  3. PublishingFilter - internal filter (in v6) to ensure that only published entities are delivered to the end user

Future Filters & Features

  1. Join data sources will become needed some day
  2. Improve ValueFilter to handle other Boolean values
  3. Improve Value Filter to handle other comparisons like Begins-With, Contains, ...
  4. Visual GUI to assemble the pipelines, so that Tokens and jS can benefit without Razor

Desired Community Contributions

  1. More filters / data sources, like...
  2. RSS-Data Source with various parameters and internal caching
  3. JSON data source with various parameters and internal caching
  4. CSV Data Source   
  5. Form & List Data Source (for accessing old F&L solutions - not sure if this is reasonable)
  6. More samples packaged as apps for download

History-Notes

  • Data Pipeline was added in v.5.x
  • Type pipelines (so that you can do pipelineName.TypeName = "Value") was added in 6.0 - previously you had to access it through pipelineName.Configuration["TypeName"] = "Value" which wasn't very clear. 
  • The DataSources ValueFilter and ValueSort were added in 6.0
  • DataSources SqlDataSource and DataTableDataSource were added in 6.0.6

Tags for this feature

2serve . 2invent . 2create is 2be.