![]() |
VOOZH | about |
dotnet add package XperienceCommunity.ContentRepository --version 1.1.0
NuGet\Install-Package XperienceCommunity.ContentRepository -Version 1.1.0
<PackageReference Include="XperienceCommunity.ContentRepository" Version="1.1.0" />
<PackageVersion Include="XperienceCommunity.ContentRepository" Version="1.1.0" />Directory.Packages.props
<PackageReference Include="XperienceCommunity.ContentRepository" />Project file
paket add XperienceCommunity.ContentRepository --version 1.1.0
#r "nuget: XperienceCommunity.ContentRepository, 1.1.0"
#:package XperienceCommunity.ContentRepository@1.1.0
#addin nuget:?package=XperienceCommunity.ContentRepository&version=1.1.0Install as a Cake Addin
#tool nuget:?package=XperienceCommunity.ContentRepository&version=1.1.0Install as a Cake Tool
This package provides a comprehensive repository pattern implementation for Kentico Xperience, offering simplified content access, enhanced caching, and streamlined dependency injection. It includes repositories for web pages, content items, and media files with advanced querying capabilities, automatic caching, and flexible configuration options.
| Xperience Version | Library Version | .NET Version |
|---|---|---|
| >= 31.5.3 | >= 1.1.0 | .NET 10 |
| >= 30.6.0 | >= 1.0.0 | .NET 8 |
Note: The latest version that has been tested is 31.5.3
Add the package to your application using the .NET CLI
dotnet add package XperienceCommunity.ContentRepository
Register the repositories in your DI container:
public void ConfigureServices(IServiceCollection services)
{
// Option 1: Configure specific types for automatic registration
services.AddXperienceContentRepositories(options =>
{
options.PageTypes = [
typeof(ArticlePage),
typeof(BlogPostPage),
typeof(HomePage)
];
options.ContentTypes = [
typeof(SharedContent),
typeof(NavigationItem),
typeof(CTAContent)
];
});
// Option 2: Use generic repositories only
services.AddXperienceContentRepositories();
}
public class ContentService
{
private readonly ContentRepositories _contentRepositories;
public ContentService(ContentRepositories contentRepositories)
{
_contentRepositories = contentRepositories;
}
public async Task<IEnumerable<ArticlePage>> GetArticlesAsync()
{
var pageRepository = _contentRepositories.GetPageRepository<ArticlePage>();
return await pageRepository.GetAll("en");
}
public async Task<IEnumerable<SharedContent>> GetSharedContentAsync()
{
var contentRepository = _contentRepositories.GetContentRepository<SharedContent>();
return await contentRepository.GetAll("en");
}
public async Task<IEnumerable<MediaFileInfo>> GetMediaFilesAsync(IEnumerable<Guid> mediaGuids)
{
var mediaRepository = _contentRepositories.GetMediaFileRepository();
return await mediaRepository.GetMediaFilesAsync(mediaGuids);
}
}
Page Type Repository: Comprehensive repository for web page content types with support for:
Content Type Repository: Full-featured repository for content items including:
Media File Repository: Specialized repository for media file operations:
ContentRepositories service for all repository accessFor detailed examples on how to use custom where conditions and other advanced features, check out the folder in this repository. It contains practical implementations showing:
This project was inspired by the excellent work done by Brandon Henricks in his Xperience by Kentico Data Repository project. We built upon those foundational concepts to create this enhanced repository pattern implementation.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.