Client Quick Start
This page gets you from service registration to a working metadata-driven page.
1. Register services
using Benevia.Core.Blazor;
using Blazored.LocalStorage;
builder.Services.AddBlazoredLocalStorage();
builder.Services.AddCoreBlazor(options =>
{
options.ApiBaseAddress = new Uri(builder.Configuration["ApiBaseUrl"]!);
});
AddCoreBlazor() registers the Core API client and the Blazor services, including component mappings
used by PropertyComponent. Non-Blazor applications can pass the same options to AddCoreClient().
2. Build a graph
Define the data shape your page needs:
private static GraphBuilder BuildGraph() => new GraphBuilder("Customer")
.Property("Id")
.Reference("BillingCustomer")
.Navigation("PrimaryContact", pc => pc
.Properties(["FirstName", "LastName", "PrimaryEmail"])
.Property("PrimaryPhone")
.Navigation("MailingAddress", ma => ma
.Property("Street")
.Property("City")
.Property("State")
.Property("PostalCode")
.Reference("Country")));
3. Create a page with DataGraph and PropertyComponent
@page "/customers/{CustomerGuid:guid}"
@page "/customers/new"
@using Benevia.Core.Blazor
@using Benevia.Core.Blazor.DynamicComponents
@using Benevia.Core.Client.DataSets
@using Benevia.Core.Client.GraphDefinitions.Builders
@using Benevia.Core.Client.OData
@using MudBlazor
@inject IODataClient OData
<DataGraph Builder="@BuildGraph" DataSet="@_dataSet" EntityGuid="@CustomerGuid">
<MudStack Spacing="4">
<MudPaper Class="pa-4 rounded-lg" Elevation="2">
<MudText Typo="Typo.h6" Class="mb-4">Profile</MudText>
<MudGrid Spacing="3">
<MudItem xs="12" sm="6">
<PropertyComponent Path="Id" />
</MudItem>
<MudItem xs="12" sm="6">
<PropertyComponent Path="PrimaryContact.FirstName" />
</MudItem>
<MudItem xs="12" sm="6">
<PropertyComponent Path="PrimaryContact.LastName" />
</MudItem>
<MudItem xs="12" sm="6">
<PropertyComponent Path="BillingCustomer" />
</MudItem>
</MudGrid>
</MudPaper>
<MudPaper Class="pa-4 rounded-lg" Elevation="2">
<MudText Typo="Typo.h6" Class="mb-4">Contact</MudText>
<MudGrid Spacing="3">
<MudItem xs="12" sm="6">
<PropertyComponent Path="PrimaryContact.PrimaryEmail" />
</MudItem>
<MudItem xs="12" sm="6">
<PropertyComponent Path="PrimaryContact.PrimaryPhone" />
</MudItem>
</MudGrid>
</MudPaper>
<MudPaper Class="pa-4 rounded-lg" Elevation="2">
<MudText Typo="Typo.h6" Class="mb-4">Mailing Address</MudText>
<MudGrid Spacing="3">
<MudItem xs="12">
<PropertyComponent Path="PrimaryContact.MailingAddress.Street" />
</MudItem>
<MudItem xs="12" sm="6">
<PropertyComponent Path="PrimaryContact.MailingAddress.City" />
</MudItem>
<MudItem xs="12" sm="3">
<PropertyComponent Path="PrimaryContact.MailingAddress.State" />
</MudItem>
<MudItem xs="12" sm="3">
<PropertyComponent Path="PrimaryContact.MailingAddress.PostalCode" />
</MudItem>
<MudItem xs="12" sm="6">
<PropertyComponent Path="PrimaryContact.MailingAddress.Country" />
</MudItem>
</MudGrid>
</MudPaper>
</MudStack>
</DataGraph>
@code {
[Parameter] public Guid? CustomerGuid { get; set; }
private DataSet _dataSet = null!;
protected override void OnInitialized()
=> _dataSet = new DataSet(OData, BuildGraph().Build());
}
4. Understand runtime flow
DataGraphrequests model metadata forCustomer.- If
CustomerGuidis set, the page loads data withDataSet.LoadAsync(guid). Otherwise it creates a new entity withDataSet.CreateAsync(). - Each
PropertyComponentresolves its editor and labels from metadata. - On edit,
DataSet.SetAsync(path, value)sends a PATCH and updates local state with the server response.