Umbraco UI Builder
CMSCloudHeartcoreDXP
13.latest (LTS)
13.latest (LTS)
  • Umbraco UI Builder Documentation
  • Known Issues
  • Release Notes
  • Installation
    • Installing Umbraco UI Builder
    • Licensing
  • Upgrading
    • Upgrading Umbraco UI Builder
    • Version Specific Upgrade Notes
    • Migrate from Konstrukt to Umbraco UI Builder
  • Getting Started
    • Overview
    • Configuration
    • User Interface
  • How-to Guides
    • Creating your first integration
  • Areas
    • Overview
    • Sections
      • Summary Dashboards
    • Trees
      • Folders
    • Dashboards
    • Context Apps
  • Collections
    • Overview
    • The Basics
    • List Views
      • Field Views
    • Editors
    • Child Collections
      • Child Collection Groups
      • Retrieve Child Collections
    • Related Collections
    • Entity Identifier Converters
  • Searching
    • Overview
    • Searchable Properties
  • Filtering
    • Overview
    • Global Filters
    • Data Views
      • Data Views Builders
    • Filterable Properties
  • Actions
    • Overview
    • The Basics
    • Action Visibility
    • Inbuilt Actions
  • Cards
    • Overview
    • Count Cards
    • Custom Cards
  • Property Editors
    • Overview
    • Entity Picker
  • Advanced
    • Virtual Sub Trees
    • Encrypted Properties
    • Value Mappers
    • Repositories
    • Events
  • Miscellaneous
    • Conventions
    • Umbraco Aliases
Powered by GitBook
On this page
  • Models Representation
  • Child Repositories
Edit on GitHub
Export as PDF
  1. Collections
  2. Child Collections

Retrieve Child Collections

Configuring **one-to-many** relationships in Umbraco UI Builder, the backoffice UI builder for Umbraco.

Retrieving child collections in one-to-many relationships with UI Builder, can be achieved with the support of child repositories. One-to-many relations are where one parent entity of a collection is associated with multiple entities from another.

Models Representation

The models would look like this:

[TableName("Students")]
[PrimaryKey("Id")]
public class Student
{
    [PrimaryKeyColumn]
    public int Id { get; set; }

    public string FirstName { get; set; }

    public string LastName { get; set; }

    public string Email { get; set; }
}
[TableName("StudentProjects")]
[PrimaryKey("Id")]
public class StudentProject
{
    [PrimaryKeyColumn]
    public int Id { get; set; }

    public string Name { get; set; }

    public int StudentId { get; set; }
}

Child Repositories

You can create child repository instances via the IRepositoryFactory and use them to retrieve information from the child collection.

public class StudentProjectController : Controller
{
    private readonly IRepositoryFactory _repositoryFactory;

    public StudentProjectController(IRepositoryFactory repositoryFactory)
    {
        _repositoryFactory = repositoryFactory;
    }

    public IActionResult Index(int projectId)
    {
        var childRepository = _repositoryFactory.GetChildRepository<int, StudentProject, int>(projectId);

        var list = childRepository.GetAll();

        var count = childRepository.GetCount();

        var listPaged = childRepository.GetPaged();

        return View(list);
    }
}
PreviousChild Collection GroupsNextRelated Collections

Last updated 1 year ago