The GetValue<TypeHere> accepts from types. Each content property has an example how how to use this method to get the data and the type to use. See the link below
To get media or content from a picker , it's a bit different, you need to pass in an instance of Mediatr. If you haven't defined it in the _imports like I have, make sure you Inject and instance of it.
The GetValue method accepts any type. Each content property editor has documentation showing the type to use.
Media Picker Properties
To get media from a media picker property:
Content Picker Properties
To get content from a content picker property:
Block List Editor Properties
To get content blocks from a Block List Editor:
Querying Content
Query Multiple Items
Use QueryContentAsync with QueryContentParameters to get multiple content items with filtering, sorting, and paging:
Query Parameters
QueryContentParameters supports these options:
Example with WhereClause
PaginatedList Result
All Query*Async methods return a PaginatedList<T> for server-side paging:
Usage example with pagination:
Get Single Item
Use Get*Async methods to retrieve a single item by ID:
Querying Other Data Types
The same patterns apply to all other services:
Media
Users
Content Types
Languages
Domains
Saving Data
Use Save*Async methods to create or update data. All save methods return a HandlerResult<T>:
HandlerResult
All save operations return a HandlerResult<T>:
Save Examples
Performance Tips
Use caching: Set Cached = true for frequently accessed, rarely changing data
AsNoTracking: Default is true for read operations (good for performance)
Limit AmountPerPage: Don't request more items than you need
Use Ids filter: When querying specific IDs, it automatically optimizes the query
Leverage WhereClause: Filter at the database level for best performance
public class PaginatedList<T>
{
public int PageIndex { get; set; }
public int TotalPages { get; set; }
public int TotalItems { get; set; }
public IEnumerable<T> Items { get; set; }
public bool HasPreviousPage => PageIndex > 1;
public bool HasNextPage => PageIndex < TotalPages;
}
@code {
protected override async Task OnInitializedAsync()
{
// Get content by ID with children
var page = await ContentService.GetContentAsync(new GetContentParameters
{
Id = contentId,
IncludeChildren = true,
IncludeParent = true,
Cached = true
});
// Shorthand for simple get by ID
var content = await ContentService.GetContent(contentId, cached: true);
}
}
// Query multiple
var mediaItems = await MediaService.QueryMediaAsync(new QueryMediaParameters
{
AmountPerPage = 20,
MediaTypes = [MediaType.Image],
OrderBy = GetMediaOrderBy.DateCreatedDescending,
Cached = true
});
// Get single
var media = await MediaService.GetMediaAsync(new GetMediaParameters
{
Id = mediaId,
IncludeParent = true
});
// Shorthand
var media = await MediaService.GetMedia(mediaId);
// Query multiple
var users = await MembershipService.QueryUsersAsync(new QueryUsersParameters
{
AmountPerPage = 50,
SearchTerm = "john",
OrderBy = GetUsersOrderBy.Name
});
// Get single
var user = await MembershipService.GetUserAsync(new GetUserParameters
{
Id = userId
});
// Query multiple
var contentTypes = await ContentService.QueryContentTypesAsync(new QueryContentTypesParameters
{
IncludeElementTypes = false,
RootOnly = true,
OrderBy = GetContentTypesOrderBy.Name
});
// Get single
var contentType = await ContentService.GetContentTypeAsync(new GetContentTypeParameters
{
Id = contentTypeId
});
// Query multiple
var languages = await LanguageService.QueryLanguagesAsync(new QueryLanguagesParameters
{
AmountPerPage = 100
});
// Get single
var language = await LanguageService.GetLanguageAsync(new GetLanguageParameters
{
Id = languageId
});
// Query multiple
var domains = await ContentService.QueryDomainAsync(new QueryDomainParameters
{
AmountPerPage = 50
});
// Get single by URL
var domain = await ContentService.GetDomainAsync(new GetDomainParameters
{
Url = "example.com"
});
@code {
private async Task SaveContent()
{
var result = await ContentService.SaveContentAsync(new SaveContentParameters
{
Content = ContentToSave
});
if (result.Success)
{
// Success! result.Entity contains the saved entity
var savedContent = result.Entity;
}
else
{
// Handle errors
foreach (var message in result.Messages)
{
// message.Message, message.MessageType (Error, Warning, Info)
}
}
}
}
public class HandlerResult<T>
{
public T? Entity { get; set; } // The saved entity
public bool Success { get; set; } // Whether operation succeeded
public List<ResultMessage> Messages { get; set; } = []; // Error/warning/info messages
public bool RefreshSignIn { get; set; } // Whether to refresh user session
}
// Save content
var contentResult = await ContentService.SaveContentAsync(new SaveContentParameters
{
Content = myContent,
UpdateContentRoles = true
});
// Save media
var mediaResult = await MediaService.SaveMediaAsync(new SaveMediaParameters
{
MediaToSave = myMedia,
FileToSave = uploadedFile,
IsUpdate = false
});
// Save user
var userResult = await MembershipService.SaveUserAsync(new SaveUserParameters
{
User = myUser,
RoleIds = selectedRoleIds
});