Data Sources
If you are about to connect your WPF application's data to a template, the first question is what form that data has today: classes, ADO.NET tables, JSON or XML. MailMerge merges each of them, and one template serves them all as long as names and hierarchy match. Here you find which method merges which kind of data, how the Reporting tab receives the same data for template design and which page covers each kind.
How Data Reaches a Template
Two classes work with the data:
MailMergemerges it. A merge method takes the data and fills the template in aTextControlorServerTextControl.DataSourceManagerdescribes it. The DataSourceManager of the WPF Reporting tab loads the same kinds of data, analyzes their tables, columns and relations and fills the drop-downs from which users insert fields and blocks.
Whatever the kind, the data becomes tables: the records you merge form the master table, whose columns fill merge fields, and nested collections or related tables fill merge blocks. Overview explains this model.
| Data | Merge with | Load for design with | Page |
|---|---|---|---|
| A business object or a collection of them, dictionaries | MergeObject, MergeObjects | LoadSingleObject, LoadObjects, LoadAssembly | Objects and Collections |
A DataTable, or a DataSet with relations | Merge | LoadDataTable, LoadDataSet | DataSets and DataTables |
| A JSON string | MergeJsonData | LoadJson | JSON and XML |
| An XML file or string | Merge, after DataSet.ReadXml | LoadXmlFile, LoadXmlString | JSON and XML |
Data source configuration files, which store a database connection for the merge, are a Windows Forms feature; Data Source Configuration Files explains what WPF applications do instead.
Data Sources in the Reporting Tab
With Select Data Source, users of the WPF Reporting tab load an XML file, an assembly or a JSON file for template design; data from a database reaches the tab only through your code, because the WPF tab can't connect a database. Reporting Ribbon and WPF Dialog Boxes describes the commands, and each page of this section shows the DataSourceManager method that loads its kind of data.
Choose a Data Source
| If your data is | Use |
|---|---|
| Classes or view models of your application, or data you query into objects | Business objects: Objects and Collections |
| Rows from a database in ADO.NET form | A DataSet with relations: DataSets and DataTables |
| The response of a web service, a file from another system | JSON or XML: JSON and XML |
Business objects and JSON carry the hierarchy of the document without extra relations, which makes them the most direct choices for new applications.
Pages in This Section
- Objects and Collections: merge business objects, dictionaries and anonymous objects, rename fields with attributes.
- DataSets and DataTables: merge tables with relations and edit relations in the Reporting tab.
- JSON and XML: merge JSON, handle invalid JSON, read XML into a
DataSetand set parsing cultures. - Data Source Configuration Files: why configuration files are Windows Forms only, and the WPF alternative.