All docs
V21.2
21.2
21.1
20.2
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

TransformationRule.Unfold Property

Gets or sets whether to unfold a complex column to display its properties or values.

Namespace: DevExpress.DataAccess.DataFederation

Assembly: DevExpress.DataAccess.v21.2.dll

Declaration

public bool Unfold { get; set; }

Property Value

Type Description
Boolean

true, to unfold data; otherwise, false.

Remarks

If a data source contains a complex column (an object), you can transform its properties to display them as separate columns. You can also create a flattened view of the original column. If one of the data columns is an array, you can unfold its values and display a new data row for every element of the array.

Create a TransformationRule object that contains transformation rules and add it to the node’s TransformationNode.Rules collection. Use the TransformationRule.Unfold and TransformationRule.Flatten properties to specify the transformation type.

Tip

You can also use Fluent API to create transformation-based queries. Refer to the TransformationNodeBuilder class description for details.

In the JSON data below, the Numbers field is an array of numbers, the Products field is an array of objects, and the Object field is an object that contain two values.

Show JSON data
[
  {
    "CategoryId": 1,
    "CategoryName": "Beverages",
    "Numbers": [ 1235, 69, 1234, 493 ],
    "Object": {
      "First": 1,
      "Second": "Second"
    },
    "Products": [
      {
        "ProductId": 1,
        "ProductName": "Chai",
        "CategoryId": 1,
        "UnitPrice": 18.0000
      },
      {
        "ProductId": 2,
        "ProductName": "Chang",
        "CategoryId": 1,
        "UnitPrice": 19.0000
      }
    ]
  },
  {
    "CategoryId": 2,
    "CategoryName": "Condiments",
    "Numbers": [ 6, 86, 127234, 896 ],
    "Object": {
      "Third": 3,
      "Fourth": "Fourth"
    },
    "Products": [
      {
        "ProductId": 3,
        "ProductName": "Aniseed Syrup",
        "CategoryId": 2,
        "UnitPrice": 10.0000
      },
      {
        "ProductId": 4,
        "ProductName": "Chef Anton's Cajun Seasoning",
        "CategoryId": 2,
        "UnitPrice": 22.0000        
      }
    ]
  }
]

The list below shows how different rules transform the source node created from this data.

Default query

TransformationNode defaultNode = new TransformationNode(sourceNode) {
    Alias = "Default",
    Rules = {
        new TransformationRule { ColumnName = "Numbers", Unfold = false, Flatten = false },
        new TransformationRule { ColumnName = "Products", Unfold = false, Flatten = false },
        new TransformationRule { ColumnName = "Object", Unfold = false, Flatten = false }
    }
};
federationDS.Queries.Add(defaultNode);

The result:

Unfolded query

TransformationNode unfoldNode = new TransformationNode(sourceNode) {
    Alias = "Unfold",
    Rules = {
        new TransformationRule { ColumnName = "Numbers", Alias = "Number", Unfold = true, Flatten = false },
        new TransformationRule { ColumnName = "Products", Alias = "Product", Unfold = true, Flatten = false },
        new TransformationRule { ColumnName = "Object", Alias = "Object", Unfold = true, Flatten = false }
    }
};
federationDS.Queries.Add(unfoldNode);

The result:

Flattened query

TransformationNode flattenNode = new TransformationNode(sourceNode) {
    Alias = "Flatten",
    Rules = {
        new TransformationRule { ColumnName = "Numbers", Unfold = false, Flatten = true },
        new TransformationRule { ColumnName = "Products", Unfold = false, Flatten = true },
        new TransformationRule { ColumnName = "Object", Unfold = false, Flatten = true }
    }
};
federationDS.Queries.Add(flattenNode);

The result:

Unfolded and flattened query

TransformationNode unfoldFlattenNode = new TransformationNode(sourceNode) {
    Alias = "Unfold and Flatten",
    Rules = { 
        new TransformationRule { ColumnName = "Numbers", Alias = "Number", Unfold = true, Flatten = true },
        new TransformationRule { ColumnName = "Products", Alias = "Product", Unfold = true, Flatten = true },
        new TransformationRule { ColumnName = "Object", Alias = "Object", Unfold = true, Flatten = true }
    }
};
federationDS.Queries.Add(unfoldFlattenNode);

The result:

The following code snippets (auto-collected from DevExpress Examples) contain references to the Unfold property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also