IViewMetadataCache

The IViewMetadataCache service provides cached access to Dataverse view (saved query) metadata. Views are retrieved from Dataverse on first access and cached for subsequent requests.

Retrieving a View by ID

Use GetAsync with the view's GUID to retrieve a single view's metadata, including its FetchXML query, columns, and display configuration.

[Inject]
private IViewMetadataCache _viewCache { get; set; } = null!;

protected override async Task OnInitializedAsync()
{
    var viewMetadata = await _viewCache.GetAsync(viewId);

    if (viewMetadata != null)
    {
        var viewName = viewMetadata.Name;
        var fetchXml = viewMetadata.FetchXml;
        var tableName = viewMetadata.TableName;
        var isDefault = viewMetadata.IsDefault;
    }
}

Retrieving All Views for a Table

Use GetAllViewsForTableAsync to retrieve all views for a specific table. Filter by ViewType to get only public views, quick find views, or lookup views.

var allViews = await _viewCache.GetAllViewsForTableAsync("contact");

// Get only public views
var publicViews = allViews
    .Where(v => v.Type == ViewType.Public)
    .ToList();

// Find the default view
var defaultView = allViews
    .FirstOrDefault(v => v.IsDefault);

Tip

Prefer IViewMetadataCache over IPowerPortalsProService.RetrieveViewMetadataAsync for reading view metadata. The cache avoids redundant network calls and is used internally by all PowerPortalsPro grid components.

IViewMetadataCache Class

Methods

Name
Parameters
Type
Description
GetAllViewsForTableAsyncstring tableName
Task<IEnumerable<ViewMetadata>>
Returns all cached view metadata for the specified table, including public, system, and user-defined views.
GetAsyncGuid key
CancellationToken token
Task<ViewMetadata>
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: GetAllViewsForTableAsync
Parameters: string tableName
Type: Task<IEnumerable<ViewMetadata>>
Description: Returns all cached view metadata for the specified table, including public, system, and user-defined views.
Name: GetAsync
Parameters: Guid key
CancellationToken token
Type: Task<ViewMetadata>
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.

ViewMetadata Class

Properties

Name
Type
Default
Description
ColumnsList<ViewColumn>
The columns displayed in the grid, including their logical names and pixel widths.
FetchXmlstring
The FetchXML query that defines which records and columns are retrieved for this view.
IsDefaultbool
False
Indicates whether this is the default view for the table.
Namestring
The display name of the view.
QuickFindCompatiblebool
False
Indicates whether this view supports Quick Find search.
TableNamestring
The logical name of the Dataverse table this view queries.
TypeViewType?
The type of view (Public, AdvancedFind, Associated, QuickFind, Lookup, etc.).
UserDefinedbool
False
Indicates whether this view was created by a user (true) or is a system view (false).
Name: Columns
Type: List<ViewColumn>
Description: The columns displayed in the grid, including their logical names and pixel widths.
Name: FetchXml
Type: string
Description: The FetchXML query that defines which records and columns are retrieved for this view.
Name: IsDefault
Type: bool
Default: False
Description: Indicates whether this is the default view for the table.
Name: Name
Type: string
Description: The display name of the view.
Name: QuickFindCompatible
Type: bool
Default: False
Description: Indicates whether this view supports Quick Find search.
Name: TableName
Type: string
Description: The logical name of the Dataverse table this view queries.
Name: Type
Type: ViewType?
Description: The type of view (Public, AdvancedFind, Associated, QuickFind, Lookup, etc.).
Name: UserDefined
Type: bool
Default: False
Description: Indicates whether this view was created by a user (true) or is a system view (false).