Creating Data Extracts
- 3 minutes to read
The Dashboard Designer allows you to create a data extract that is a compressed snapshot of data obtained from the existing data source.
Note
Note that data extracts cannot be created for the OLAP Data Source.
Creating a Data Extract in the Data Source Wizard
To create a new data extract from the existing data source, perform the following steps.
Click the New Data Source button in the Data Source ribbon tab.
On the first page of the invoked Data Source Wizard dialog, select Data extract and click Next.
On the next page, select whether to create a new data extract or establish a connection to an existing one.
- To create a new data extract, select Create a new data extract from the existing data source and specify the required Data Source and Data Member. Click Next.
- To establish a connection to an existing data extract, select Load an existing data extract from a file and locate the required *.dat file. Click Finish.
(Conditional) The next page only appears if you are creating the data extract based on the Entity Framework Data Source or Object Data Source and allows you to select the required fields.
On the next page, you can specify the filter used to extract data. To learn how to specify the filter criteria, see Filter Data via the Filter Editor.
You can also limit the number of extracted rows by enabling the Limit rows to extract option and specifying the required number of rows. Click Next.
Note
Use the Preview button to see the data that will be placed into the resulting data extract.
(Conditional) The next page only appears if the original data source contains parameters (for instance, the SQL query is filtered using a dashboard parameter).
On the final page, specify a path to the file that will contain the resulting data extract.
Click Finish. This creates the data extract and displays its fields in the Data Source Browser. You can use this data extract as a regular data source.
Creating a Data Extract in Code
To generate the data extract in code, create an instance of the DashboardExtractDataSource class and specify the following properties.
- Specify the original data source using the ExtractSourceOptions.DataSource property. To access the ExtractSourceOptions class, use the DashboardExtractDataSource.ExtractSourceOptions property.
- Specify the required data member from the data source using the ExtractSourceOptions.DataMember property.
Note
Note that the data member should be specified for the SQL or Entity Framework data sources only.
- Specify the path to the resulting extract file using the DashboardExtractDataSource.FileName property and call the DashboardExtractDataSource.UpdateExtractFile method to create this file.
Finally, add the created DashboardExtractDataSource object to the Dashboard.DataSources collection.
The following code snippet shows how to create a data extract from the existing SQL data source and add it to the collection of dashboard data sources.
using DevExpress.DashboardCommon;
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
// ...
DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("Data Source 1", msSqlParams);
SelectQuery selectQuery = SelectQueryFluentBuilder
.AddTable("SalesPerson")
.SelectColumns("CategoryName", "Extended Price")
.Build("Query 1");
sqlDataSource.Queries.Add(selectQuery);
// ...
DashboardExtractDataSource extractDataSource = new DashboardExtractDataSource();
extractDataSource.ExtractSourceOptions.DataSource = sqlDataSource;
extractDataSource.ExtractSourceOptions.DataMember = "Query 1";
extractDataSource.FileName = @"C:\temp\SalesPersonExtract.dat";
extractDataSource.UpdateExtractFile();
dashboard.DataSources.Add(extractDataSource);