> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/umbraco-ui-builder/filtering/data-views/data-views-builders.md).

# Data Views Builders

Learn how to configure data views builders in Umbraco UI Builder.

Data views builders allow you to create a collection’s data views dynamically at runtime. By default, Umbraco UI Builder uses hard-coded data views from the configuration. However, if you need to generate data views dynamically, a data views builder is required.

When resolving a data views builder, Umbraco UI Builder first attempts to retrieve it from the global Dependency Injection (DI) container. This allows injecting required dependencies into the builder. If no type is defined in the DI container, Umbraco UI Builder falls back to manually instantiating a new instance of the value mapper.

## Defining a Data Views Builder

To define a data views builder, create a class that inherits from `DataViewsBuilder<TEntityType>` and implements the required abstract methods.

```csharp
// Example
public class PersonDataViewsBuilder : DataViewsBuilder<Person>
{
    public override IEnumerable<DataViewSummary> GetDataViews()
    {
        // Generate and return a list of data views
    }

    public override Expression<Func<Person, bool>> GetDataViewWhereClause(string dataViewAlias)
    {
        // Return a where clause expression for the supplied data view alias
    }
}
```

The required methods are:

* **GetDataViews:** Returns the list of data views to choose from.
* **GetDataViewWhereClause:** Returns the boolean **where clause** expression for the given data views alias.

## Setting the Data Views Builder of a Collection

Setting a data views builder is controlled via the [Collections](/umbraco-ui-builder/collections/overview.md) settings.

### Using the `SetDataViewsBuilder()` Method

Sets the collection's data views builder, allowing you to define data views dynamically at runtime.

#### Method Syntax

```cs
SetDataViewsBuilder<TDataViewsBuilder>() : CollectionConfigBuilder<TEntityType>
```

#### Example

```csharp
collectionConfig.SetDataViewsBuilder<PersonDataViewsBuilder>();
```

### Using the `SetDataViewsBuilder(Type)` Method

Sets the collection's data views builder, allowing you to define data views dynamically at runtime.

#### Method Syntax

```cs
SetDataViewsBuilder(Type dataViewsBuilderType) : CollectionConfigBuilder<TEntityType>
```

#### Example

```csharp
collectionConfig.SetDataViewsBuilder(typeof(PersonDataViewsBuilder));
```

### Using the `SetDataViewsBuilder(DataViewsBuilder<TEntityType>)` Method

Sets the collection's data views builder, allowing you to define data views dynamically at runtime.

#### Method Syntax

```cs
SetDataViewsBuilder(DataViewsBuilder<TEntityType> dataViewsBuilder) : CollectionConfigBuilder<TEntityType>
```

#### Example

```csharp
collectionConfig.SetDataViewsBuilder(new PersonDataViewsBuilder());
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbraco.com/umbraco-ui-builder/filtering/data-views/data-views-builders.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
