Repositories
Configuring repositories in Konstrukt, the back office UI builder for Umbraco.
Defining a repository
// Example
public class PersonRepository : KonstruktRepository<Person, int> {
public PersonRepository(KonstruktRepositoryContext context)
: base(context)
{ }
protected override int GetIdImpl(Person entity) {
return entity.Id;
}
protected override Person GetImpl(int id) {
...
}
protected override Person SaveImpl(Person entity) {
...
}
protected override void DeleteImpl(int id) {
...
}
protected override IEnumerable<Person> GetAllImpl(Expression<Func<Person, bool>> whereClause, Expression<Func<Person, object>> orderBy, SortDirection orderByDirection) {
...
}
protected override PagedResult<Person> GetPagedImpl(int pageNumber, int pageSize, Expression<Func<Person, bool>> whereClause, Expression<Func<Person, object>> orderBy, SortDirection orderByDirection) {
...
}
protected override long GetCountImpl(Expression<Func<Person, bool>> whereClause) {
...
}
}Changing the repository implementation of a collection
SetRepositoryType<TRepositoryType>() : KonstruktCollectionConfigBuilder<TEntityType>
SetRepositoryType(Type repositoryType) : KonstruktCollectionConfigBuilder<TEntityType>
Accessing a repository in code
IKonstruktRepositoryFactory.GetRepository<TEntity, TId>() : KonstruktRepository<TEntity, TId>
IKonstruktRepositoryFactory.GetRepository<TEntity, TId>(string collectionAlias) : KonstruktRepository<TEntity, TId>
Last updated