All docs
V20.1
20.1
19.2
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.

ObjectDataSource.RebuildResultSchema() Method

Builds the ObjectDataSource schema.

Namespace: DevExpress.DataAccess.ObjectBinding

Assembly: DevExpress.DataAccess.v20.1.dll

Declaration

public void RebuildResultSchema()
Public Sub RebuildResultSchema

Remarks

Call this method to build the data source schema. You can use the schema to bind controls to data source fields.

Use the RebuildResultSchema(IEnumerable<IParameter>) method instead to apply values from external parameters (for instance, report parameters) to the data source parameters before the schema is built.

Example

The code sample below configures an object data source and calls the RebuildResultSchema method to build the data source schema.

using System.Collections.Generic;
using DevExpress.DataAccess;
using DevExpress.DataAccess.ObjectBinding;
// ...
public class Employee {
    public string Name { get; set; }
    public string Position { get; set; }
}
// The class that fetches data to the ObjectDataSource.
public static class EmployeeDataSource {
    public static IEnumerable<Employee> GetEmployeeList(bool fetchData) {
        if (!fetchData)
            return null;
        var employees = new List<Employee>() {
                new Employee() {
                    Name = "Andrew Fuller",
                    Position = "Vice President, Sales"
                },
                new Employee() {
                    Name = "Nancy Davolio",
                    Position = "Sales Representative"
                },
                new Employee() {
                    Name = "Maria Anders",
                    Position = "Sales Representative"
                },
                new Employee() {
                    Name = "Ana Trujillo",
                    Position = "Owner"
                },
                new Employee() {
                    Name = "Antonio Moreno",
                    Position = "Sales Representative"
                },
                new Employee() {
                    Name = "Thomas Hardy",
                    Position = "Sales Representative"
                },
                new Employee() {
                    Name = "Christina Berglund",
                    Position = "Order Administrator"
                },
                new Employee() {
                    Name = "Frédérique Citeaux",
                    Position = "Marketing Manager"
                },
                new Employee() {
                    Name = "Hanna Moos",
                    Position = "Sales Representative"
                },
            };
        return employees;
    }
}
// ...
// Create an ObjectDataSource instance.
ObjectDataSource dataSource = new ObjectDataSource();
dataSource.Name = "objectDataSource1";
dataSource.DataSource = typeof(EmployeeDataSource);
// Specify the data member.
dataSource.DataMember = "GetEmployeeList";
// Specify the data source parameters.
dataSource.Parameters.Add(new Parameter("fetchData", typeof(bool), true));
// Build the data source schema.
dataSource.RebuildResultSchema();
See Also