Reporting Data Source Factory

Last Updated: 03/28/2018 Introduced in Version:


Creating custom data sources for reports is useful when you know ahead of time what all of the data sources will be. When the list of data sources can only be known at runtime, it’s useful to create a data source factory that can create the necessary list of data sources at runtime. The Decisions SDK provides classes that help you create data source factories. An example of doing that is detailed below.

Please review the documentation on creating a Custom Reporting Data Source if necessary, as it describes the type of data source that the data source factory will provide for Decisions.


A Simple Data Source Factory

Before creating a data source factory class, create the class that represents the various data sources the factory will produce. As an example, let’s examine a case where each data source reads its information from a database table. 


The class below is a Data Source that takes a database table name as a parameter in its constructor.  Based on that, the class returns the columns it wants to provide to reports in the ReportFields property, and the report data from the GetData() method.

Note that this class has the [Writable] attribute applied to it.  This is required when a data source is used by a data source factory.  Because a data source factory will be registering instances of this data source class, the [AutoRegisterReportElement] attribute mentioned in the Custom Reporting Data Source example is not used.


Now a data source factory can be created, which creates objects of the TableDataSource class and returns them:

The [AutoRegisterReportElementFactory] attribute tells Decisions that this class is a factory that provides Reporting Data Sources.  Decisions will call the GetFilters() method to retrieve the data sources and make them available in the selection list for report designers to pick from.  After building these two classes in a project with the Decisions SDK and installing it (for details, see Creating a Module), the two TableDataSources appear:

Additional Resources