ITableMetadataCache

The ITableMetadataCache service provides cached access to Dataverse table metadata. It retrieves table metadata from Dataverse on first access and caches it for subsequent requests, avoiding repeated round trips to the server.

Usage

Inject ITableMetadataCache and call GetAsync with the table's logical name. The first call retrieves the metadata from Dataverse; subsequent calls return the cached value.

React Blazor

What's Included

The returned TableMetadata object includes:

  • Columns — A collection of column metadata including data types, validation rules, labels, and constraints.
  • PrimaryIdColumn / PrimaryNameColumn — The logical names of the table's primary key and primary name columns.
  • OneToMany / ManyToOne / ManyToMany — Relationship metadata for navigating between related tables.
  • PrimaryImageColumn — The logical name of the table's primary image column, if one exists.

Accessing Column Metadata

Use the Columns collection to look up metadata for a specific column. Cast to the appropriate metadata type (e.g. StringMetadata, LookupMetadata, ChoiceMetadata) for type-specific properties like max length, target tables, or option values.

React Blazor

Accessing Relationship Metadata

Use the OneToMany, ManyToOne, and ManyToMany collections to look up relationship metadata by relationship name. This is used internally by SubGrid and ManyToManyLookupEdit to resolve related tables and build queries.

React Blazor

Tip

Prefer ITableMetadataCache over IPowerPortalsProService.RetrieveTableMetadataAsync for reading table metadata. The cache avoids redundant network calls and is used internally by all PowerPortalsPro components.

ITableMetadataCache Interface

Methods

Name
Parameters
Type
Description
GetAllHeadersAsyncCancellationToken token
Task<IReadOnlyList<TableHeader>>
Returns the identity-level metadata — logical, schema and display name plus a few flags — for every table in the environment, ordered by display name. Cached alongside the per-table entries rather than on a separate path, because it is the same expensive resource read a different way: retrieving table metadata is heavy, and every caller should be served from the cache rather than re-querying Dataverse. Populating a table picker is the motivating case — asking Threading.CancellationToken) for a thousand tables to fill a dropdown would retrieve every column of every one of them.
GetAsyncstring key
CancellationToken token
Task<TableMetadata>
Retrieves an item from the cache by key. If the item is not cached, it is fetched from the underlying source, cached, and returned.
GetManyAsyncIReadOnlyList<TableMetadataRequest> requests
CancellationToken token
Task<IReadOnlyList<TableMetadata>>
Returns several tables' metadata at once, each narrowed to the columns and relationships its request names. The middle ground between the two reads above: whole-table for one table, or identity-only for every table. This is for the caller that wants a little from each of many — the display names of the lookup columns behind a table's relationships, say, which live on the related tables rather than on the one being queried. Sliced from what the cache already holds, so asking about thirty tables is thirty dictionary lookups rather than thirty retrievals. Narrowing changes which columns come back, not what each carries: a named column arrives as fully described as it would from a whole-table read. A table the environment does not have is simply absent from the result rather than throwing — a batch is easier to read back by matching on table name than by lining it up positionally.
Name: GetAllHeadersAsync
Parameters: CancellationToken token
Type: Task<IReadOnlyList<TableHeader>>
Description: Returns the identity-level metadata — logical, schema and display name plus a few flags — for every table in the environment, ordered by display name. Cached alongside the per-table entries rather than on a separate path, because it is the same expensive resource read a different way: retrieving table metadata is heavy, and every caller should be served from the cache rather than re-querying Dataverse. Populating a table picker is the motivating case — asking Threading.CancellationToken) for a thousand tables to fill a dropdown would retrieve every column of every one of them.
Name: GetAsync
Parameters: string key
CancellationToken token
Type: Task<TableMetadata>
Description: Retrieves an item from the cache by key. If the item is not cached, it is fetched from the underlying source, cached, and returned.
Name: GetManyAsync
Parameters: IReadOnlyList<TableMetadataRequest> requests
CancellationToken token
Type: Task<IReadOnlyList<TableMetadata>>
Description: Returns several tables' metadata at once, each narrowed to the columns and relationships its request names. The middle ground between the two reads above: whole-table for one table, or identity-only for every table. This is for the caller that wants a little from each of many — the display names of the lookup columns behind a table's relationships, say, which live on the related tables rather than on the one being queried. Sliced from what the cache already holds, so asking about thirty tables is thirty dictionary lookups rather than thirty retrievals. Narrowing changes which columns come back, not what each carries: a named column arrives as fully described as it would from a whole-table read. A table the environment does not have is simply absent from the result rather than throwing — a batch is easier to read back by matching on table name than by lining it up positionally.