Skip to content

Commit 165e3fe

Browse files
author
Evgeny Polevikov
authored
Merge pull request #4 from epolevikov/update-topic-on-federated-query
Update topic on federated query
2 parents 217c451 + 265c57c commit 165e3fe

File tree

35 files changed

+197
-42
lines changed

35 files changed

+197
-42
lines changed

interface-elements-for-desktop/articles/report-designer/report-designer-for-winforms/bind-to-data/bind-a-report-to-a-join-based-federated-data-source.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,22 @@ This topic describes how to create a federated data source that joins data from
3434

3535
![](../../../../images/eurd-data-federation-query-builder-drop-table.png)
3636

37-
5. Drag and drop the Excel data source onto the design surface. In the invoked **Join Editor**, select the **Inner join** type and create a relationship based on the key field.
37+
5. Drag and drop the Excel data source onto the design surface. In the invoked **Join Editor**, select the **Inner join** type and create a relationship based on the **CategoryID** key field.
3838

3939
![](../../../../images/eurd-data-federation-query-builder-join-tables.png)
4040

4141
6. Enable checkboxes for the data fields you want to include in the query result set.
4242

4343
![](../../../../images/eurd-data-federation-query-builder-select-fields.png)
4444

45+
You can specify a different name for a field. Click the field's **Alias** cell and type the alias.
46+
47+
![](../../../../images/eurd-data-federation-query-builder-specify-alias.png)
48+
49+
Use the grid's empty line to add an unbound field to a query. Click the field's ellipsis button to invoke the [Expression Editor](../use-expressions.md) and construct an expression that specifies the field's value.
50+
51+
![](../../../../images/eurd-data-federation-query-builder-construct-expression.png)
52+
4553
7. Click **OK** to close the Query Builder. Click **Finish** to complete the Data Source Wizard.
4654

4755
The Wizard creates a new **FederationDataSource** that includes the single query. This data source becomes available in the [Report Explorer](../../../../articles/report-designer/report-designer-for-winforms/report-designer-tools/ui-panels/report-explorer.md)'s **Components** node. The [Field List](../../../../articles/report-designer/report-designer-for-winforms/report-designer-tools/ui-panels/field-list.md) reflects the data source structure.
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
---
2+
title: Bind a Report to a Transformation-Based Data Source
3+
author: Eugene Polevikov
4+
---
5+
6+
# Bind a Report to a Transformation-Based Data Source
7+
8+
If you bind a report to a [JSON](bind-a-report-to-json-data.md), [Object](bind-a-report-to-an-object-data-source.md), [Entity Framework](bind-a-report-to-an-entity-framework-data-source.md), or [XPO](bind-a-report-to-an-xpo-persistent-object.md) data source that contains a collection property, you can flatten the data source structure:
9+
10+
![](../../../../images/federated-data-source-transformation.png)
11+
12+
This tutorial illustrates how to use the **Federation Data Source**'s **Transformation** mode to flatten a JSON Data Source that contains a collection property.
13+
14+
## Create a Report and Bind it to a Data Source
15+
16+
1. [Create a new blank report](../add-new-reports.md)
17+
18+
2. [Add a JSON data source](bind-a-report-to-json-data.md)
19+
20+
This tutorial uses the following JSON string:
21+
22+
```
23+
[
24+
{
25+
"CategoryId": 1,
26+
"CategoryName": "Beverages",
27+
"Description": "Soft drinks, coffees, teas, beers, and ales",
28+
"Products": [
29+
{
30+
"ProductId": 1,
31+
"ProductName": "Chai",
32+
"SupplierId": 1,
33+
"CategoryId": 1,
34+
"QuantityPerUnit": "10 boxes x 20 bags",
35+
"UnitPrice": 18.0000,
36+
"UnitsInStock": 39,
37+
"UnitsOnOrder": 0,
38+
"ReorderLevel": 10,
39+
"Discontinued": false,
40+
"Supplier": null
41+
},
42+
{
43+
"ProductId": 2,
44+
"ProductName": "Chang",
45+
"SupplierId": 1,
46+
"CategoryId": 1,
47+
"QuantityPerUnit": "24 - 12 oz bottles",
48+
"UnitPrice": 19.0000,
49+
"UnitsInStock": 17,
50+
"UnitsOnOrder": 40,
51+
"ReorderLevel": 25,
52+
"Discontinued": false,
53+
"Supplier": null
54+
}
55+
]
56+
},
57+
{
58+
"CategoryId": 2,
59+
"CategoryName": "Condiments",
60+
"Description": "Sweet and savory sauces, relishes, spreads, and seasonings",
61+
"Products": [
62+
{
63+
"ProductId": 3,
64+
"ProductName": "Aniseed Syrup",
65+
"SupplierId": 1,
66+
"CategoryId": 2,
67+
"QuantityPerUnit": "12 - 550 ml bottles",
68+
"UnitPrice": 10.0000,
69+
"UnitsInStock": 13,
70+
"UnitsOnOrder": 70,
71+
"ReorderLevel": 25,
72+
"Discontinued": false,
73+
"Supplier": null
74+
},
75+
{
76+
"ProductId": 4,
77+
"ProductName": "Chef Anton's Cajun Seasoning",
78+
"SupplierId": 2,
79+
"CategoryId": 2,
80+
"QuantityPerUnit": "48 - 6 oz jars",
81+
"UnitPrice": 22.0000,
82+
"UnitsInStock": 53,
83+
"UnitsOnOrder": 0,
84+
"ReorderLevel": 0,
85+
"Discontinued": false,
86+
"Supplier": null
87+
}
88+
]
89+
}
90+
]
91+
```
92+
93+
The [Field List](../report-designer-tools/ui-panels/field-list.md) displays the created JSON data source.
94+
95+
![](../../../../images/federated-data-source-json-field-list.png)
96+
97+
## Create Data Federation and Transform the Data Source
98+
99+
1. Click the report's smart tag, expand the **DataSource** property's drop-down menu, and click **Add Report Data Source**.
100+
101+
![](../../../../images/federated-data-source-add-federated-data-source.png)
102+
103+
2. In the invoked **Data Source Wizard**, select **Data Federation** and click **Next**.
104+
105+
![](../../../../images/data-federation-wizard-choose-data-federation.png)
106+
107+
3. On the next page, click **Add Query**.
108+
109+
![](../../../../images/federated-data-source-add-query.png)
110+
111+
4. In the invoked [Query Builder](../report-designer-tools/query-builder.md), select the **Transformation** query type. Select the data source or query that contains columns you want to transform. Select the **Transform** check box next to the column you need to unfold and flatten. The bottom pane allows you to specify the aliases for the generated columns.
112+
113+
![](../../../../images/federated-data-source-transformation-query.png)
114+
115+
Click **OK** to create the query and click **Finish** to create the data source.
116+
117+
The **Field List** displays the created Federation Data Source.
118+
119+
![](../../../../images/federated-data-source-result.png)
120+
121+
## Prepare the Report Layout
122+
123+
1. Set the **Landscape** orientation for report pages. Select the report and switch to the **Properties** panel. Enable the **Landscape** property.
124+
125+
![Set Landscape Page Orientation](../../../../images/federated-data-source-landscape-orientation.png)
126+
127+
2. Drop data fields from the **Field List** onto the report's [Detail](../introduction-to-banded-reports.md) band. Hold CTRL or SHIFT and click the fields to select multiple fields.
128+
129+
![Drop Fields Onto the Report](../../../../images/federated-data-source-drop-fields.png)
130+
131+
3. Add a **ReportHeader** band to the report. Right-click the report and select **Insert Band** / **ReportHeader**.
132+
133+
![Add Report Header](../../../../images/federated-data-source-insert-reportheader.png)
134+
135+
4. Create headers for the report columns. Select data fields and drop them onto the added **ReportHeader** band with the right mouse button.
136+
137+
![Drop Table Headers](../../../../images/federated-data-source-drop-headers.png)
138+
139+
5. Change header titles as necessary. Double-click a cell and type the new title.
140+
141+
![Change Header Titles](../../../../images/federated-data-source-change-header-titles.png)
142+
143+
6. Resize report columns. Select cells and drag their edges.
144+
145+
![Resize Table Cells](../../../../images/federated-data-source-resize-cells.png)
146+
147+
7. Change the header cells' appearance. Select cells and specify the following properties:
148+
149+
| Property | Value |
150+
| --- | --- |
151+
| **Foreground Color** | White |
152+
| **Background Color** | DimGray |
153+
| **Padding** | 10, 10, 0, 0 |
154+
| **Font** | Arial, 9pt, style=Bold |
155+
156+
![Change Cell Appearance](../../../../images/federated-data-source-change-cell-appearance.png)
157+
158+
8. Change the band heights to match the table rows. Select the bands and drag their edges the same way as for the table cells.
159+
160+
9. Add a style for the table's even rows. Select **TableRow2** in the **Properties** window, expand the **Styles** property, and select **New** for the **Even Style** property. Then select **Style1** and set the **Background Color** property to **216, 216, 216**.
161+
162+
![Set Even Style](../../../../images/federated-data-source-set-even-style.png)
163+
164+
10. Format the price values. Select the cell that displays the **Products_UnitPrice** value and set its [Format String] to **{0:c2}**.
165+
166+
![Specify Cell Format](../../../../images/federated-data-source-set-format-string.png)
167+
168+
The report is ready. Upper-level data source records are repeated as many times as there are flattened records:
169+
170+
![Records Repeated](../../../../images/federation-data-source-report-result.png)

interface-elements-for-desktop/articles/report-designer/report-designer-for-winforms/bind-to-data/bind-a-report-to-a-union-based-federated-data-source.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,12 @@ You can create a federated data source for your report to display data combined
4848
<!--image-->
4949
![](../../../../images/DataFederationUnion-Common-Fields.png)
5050

51-
6. Enable check boxes for the data fields you want to include in the query result set.
52-
53-
<!--image-->
54-
55-
7. Rename fields.
51+
6. Rename fields.
5652

5753
<!--image-->
5854
![](../../../../images/DataFederation-FieldAliases.png)
5955

60-
8. Click **OK** to close the Query Builder. Click **Finish** to complete the Data Source Wizard.
56+
7. Click **OK** to close the Query Builder. Click **Finish** to complete the Data Source Wizard.
6157

6258
The Wizard creates a new **FederationDataSource** that includes the single **Customers** query. This data source becomes available in the [Report Explorer](../../../../articles/report-designer/report-designer-for-winforms/report-designer-tools/ui-panels/report-explorer.md)'s **Components** node. The [Field List](../../../../articles/report-designer/report-designer-for-winforms/report-designer-tools/ui-panels/field-list.md) reflects the data source structure.
6359

interface-elements-for-desktop/articles/report-designer/report-designer-for-winforms/report-designer-tools/data-source-wizard/connect-to-a-federated-data-source/create-a-federated-query.md

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,55 +15,32 @@ Enable check boxes for data fields, queries and/or entire data sources.
1515

1616
The selected items are included in data federation as separate queries based on initial data source queries.
1717

18-
![](../../../../../../images/eurd-win-data-federation-queries-field-list.png)
18+
![](../../../../../../images/data-federation-queries-field-list.png)
1919

2020
The wizard specifies query names as follows:
2121

2222
* If the initial data source contains one or more queries (such as in a SQL data source), the federated query name consists of the data source name and query name separated by an underscore.
2323
* If the initial data source contains data at the root level (such as in an Excel data source), federated query name is equivalent to the data source name.
2424

25+
Right-click the federated data source and choose **Manage Relations**. This invokes the **Master-Detail Relation Editor** you can use to [specify a master-detail relationship](#specify-master-detail-relationships) between the separate queries.
26+
27+
![](../../../../../../images/data-federation-queries-field-list-manage-relations.png)
28+
2529
## Combine Data into a Single Query
2630

2731
To combine data from multiple data sources into a single query, click **Add Query**.
2832

2933
![](../../../../../../images/eurd-win-data-source-wizard-data-federation-add-query.png)
3034

31-
This invokes the [Query Builder](../../query-builder.md) adapted to federated data sources. Specify the query type.
35+
This invokes the [Query Builder](../../query-builder.md) designed to federated data sources.
3236

3337
![](../../../../../../images/DataFederationUnion-Specify-Query-Type.png)
3438

35-
- **Join**
36-
37-
Drag and drop items onto the design surface, and specify join relationships in the **Join Editor**.
38-
39-
![](../../../../../../images/eurd-win-data-source-wizard-data-federation-join-data.png)
40-
41-
Enable check boxes for the data fields you want to include in the query result set.
42-
43-
![](../../../../../../images/eurd-win-data-source-wizard-data-federation-join-select-fields.png)
44-
45-
- **Union and Union All**
46-
47-
Double-click the data sources you want to combine into a single query. The query includes only fields that have identical names and types in the origin sources.
48-
49-
![](../../../../../../images/DataFederationUnion-Common-Fields.png)
39+
You can use the **Join**, **Union**, **Union All**, and **Transform** query types to combine data. Refer to the following articles for more information on these query types.
5040

51-
Rename fields.
52-
53-
![](../../../../../../images/DataFederation-FieldAliases.png)
54-
55-
> [!Tip]
56-
> When you use the **Union** mode, duplicate data from the origin data sources is removed from the query result set. Use the **Union All** mode to include all data.
57-
58-
The created query appears on the wizard page in the **Federated Queries** category. The federated query's default name is equivalent to the main table name.
59-
60-
![](../../../../../../images/eurd-win-data-source-wizard-data-federation-join-query.png)
61-
62-
You can click the ![report-wizard-multi-query-page-icon-edit](../../../../../../images/eurd-win-report-wizard-multi-query-page-icon-edit125534.png) button to customize the query or the ![report-wizard-multi-query-page-icon-remove](../../../../../../images/eurd-win-report-wizard-multi-query-page-icon-remove125533.png) button to remove the query.
63-
64-
Once you finish the wizard, it creates a federated data source that includes a single query.
65-
66-
![](../../../../../../images/eurd-win-data-federation-single-query-field-list.png)
41+
* [Bind a Report to a Join-Based Federated Data Source](../../../bind-to-data/bind-a-report-to-a-join-based-federated-data-source.md)
42+
* [Bind a Report to a Union-Based Federated Data Source](../../../bind-to-data/bind-a-report-to-a-union-based-federated-data-source.md)
43+
* Bind a Report to a Transformation-Based Data Source
6744

6845
## Specify Master-Detail Relationships
6946

@@ -77,4 +54,6 @@ In the invoked editor, drag and drop the key field from the master query to the
7754

7855
Once the wizard is complete, you can see the master-detail hierarchy in the Field List.
7956

80-
![](../../../../../../images/eurd-win-data-federation-master-detail-hierarchy-field-list.png)
57+
![](../../../../../../images/data-federation-master-detail-hierarchy-field-list.png)
58+
59+
For more information, refer to the following guide: [Bind a Report to a Federated Master-Detail Data Source](../../../bind-to-data/bind-a-report-to-a-federated-master-detail-data-source.md).
1.34 KB
Loading
1.75 KB
Loading
2.47 KB
Loading
1.26 KB
Loading
1.26 KB
Loading
12.3 KB
Loading

0 commit comments

Comments
 (0)