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
IViewMetadataCacheoverIPowerPortalsProService.RetrieveViewMetadataAsyncfor 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 |
|---|---|---|---|
GetAllViewsForTableAsync | string tableName | Task<IEnumerable<ViewMetadata>> | Returns all cached view metadata for the specified table, including public, system, and user-defined views. |
GetAsync | Guid 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:
GetAllViewsForTableAsyncParameters:
string tableName
Type:
Task<IEnumerable<ViewMetadata>>
Description:
Returns all cached view metadata for the specified table, including public, system, and user-defined views.
Name:
GetAsyncParameters:
Guid key
CancellationToken token
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 |
|---|---|---|---|
Columns | List<ViewColumn> | The columns displayed in the grid, including their logical names and pixel widths. | |
FetchXml | string | The FetchXML query that defines which records and columns are retrieved for this view. | |
IsDefault | bool | False | Indicates whether this is the default view for the table. |
Name | string | The display name of the view. | |
QuickFindCompatible | bool | False | Indicates whether this view supports Quick Find search. |
TableName | string | The logical name of the Dataverse table this view queries. | |
Type | ViewType? | The type of view (Public, AdvancedFind, Associated, QuickFind, Lookup, etc.). | |
UserDefined | bool | False | Indicates whether this view was created by a user (true) or is a system view (false). |
Name:
ColumnsType:
List<ViewColumn>
Description:
The columns displayed in the grid, including their logical names and pixel widths.
Name:
FetchXmlType:
string
Description:
The FetchXML query that defines which records and columns are retrieved for this view.
Name:
IsDefaultType:
bool
Default:
False
Description:
Indicates whether this is the default view for the table.
Name:
NameType:
string
Description:
The display name of the view.
Name:
QuickFindCompatibleType:
bool
Default:
False
Description:
Indicates whether this view supports Quick Find search.
Name:
TableNameType:
string
Description:
The logical name of the Dataverse table this view queries.
Name:
TypeType:
ViewType?
Description:
The type of view (Public, AdvancedFind, Associated, QuickFind, Lookup, etc.).
Name:
UserDefinedType:
bool
Default:
False
Description:
Indicates whether this view was created by a user (true) or is a system view (false).
