Rystem.RepositoryFramework.Abstractions 1.1.14

There is a newer version of this package available.
See the version list below for details.
dotnet add package Rystem.RepositoryFramework.Abstractions --version 1.1.14
                    
NuGet\Install-Package Rystem.RepositoryFramework.Abstractions -Version 1.1.14
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Rystem.RepositoryFramework.Abstractions" Version="1.1.14" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rystem.RepositoryFramework.Abstractions" Version="1.1.14" />
                    
Directory.Packages.props
<PackageReference Include="Rystem.RepositoryFramework.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Rystem.RepositoryFramework.Abstractions --version 1.1.14
                    
#r "nuget: Rystem.RepositoryFramework.Abstractions, 1.1.14"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Rystem.RepositoryFramework.Abstractions@1.1.14
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Rystem.RepositoryFramework.Abstractions&version=1.1.14
                    
Install as a Cake Addin
#tool nuget:?package=Rystem.RepositoryFramework.Abstractions&version=1.1.14
                    
Install as a Cake Tool

What is Rystem?

Interfaces

Based on CQRS we could split our repository pattern in two main interfaces, one for update (write, delete) and one for read.

Command (Write-Delete)
public interface ICommandPattern<T, TKey, TState> : ICommandPattern
    where TKey : notnull
    where TState : class, IState<T>, new()
{
    Task<TState> InsertAsync(TKey key, T value, CancellationToken cancellationToken = default);
    Task<TState> UpdateAsync(TKey key, T value, CancellationToken cancellationToken = default);
    Task<TState> DeleteAsync(TKey key, CancellationToken cancellationToken = default);
    Task<List<BatchResult<TKey, TState>>> BatchAsync(List<BatchOperation<T, TKey>> operations, CancellationToken cancellationToken = default);
}
Query (Read)
public interface IQueryPattern<T, TKey, TState> : IQueryPattern
    where TKey : notnull
    where TState : class, IState<T>, new()
{
    Task<T?> GetAsync(TKey key, CancellationToken cancellationToken = default);
    Task<TState> ExistAsync(TKey key, CancellationToken cancellationToken = default);
    Task<IEnumerable<T>> QueryAsync(QueryOptions<T>? options = null, CancellationToken cancellationToken = default);
    Task<long> CountAsync(QueryOptions<T>? options = null, CancellationToken cancellationToken = default);
}
Repository Pattern (Write-Delete-Read)

Repository pattern is a sum of CQRS interfaces.

public interface IRepositoryPattern<T, TKey, TState> : ICommandPattern<T, TKey, TState>, IQueryPattern<T, TKey, TState>, IRepositoryPattern, ICommandPattern, IQueryPattern
    where TKey : notnull
    where TState : class, IState<T>, new()
{
}

With State as TState

Command (Write-Delete)
public interface ICommandPattern<T, TKey> : ICommandPattern<T, TKey, State<T>>, ICommandPattern
    where TKey : notnull
{
    Task<State<T>> InsertAsync(TKey key, T value, CancellationToken cancellationToken = default);
    Task<State<T>> UpdateAsync(TKey key, T value, CancellationToken cancellationToken = default);
    Task<State<T>> DeleteAsync(TKey key, CancellationToken cancellationToken = default);
    Task<List<BatchResult<TKey, State<T>>>> BatchAsync(List<BatchOperation<T, TKey>> operations, CancellationToken cancellationToken = default);
}
Query (Read)
public interface IQueryPattern<T, TKey> : IQueryPattern<T, TKey, State<T>>, IQueryPattern
    where TKey : notnull
{
    Task<T?> GetAsync(TKey key, CancellationToken cancellationToken = default);
    Task<State<T>> ExistAsync(TKey key, CancellationToken cancellationToken = default);
    Task<IEnumerable<T>> QueryAsync(QueryOptions<T>? options = null, CancellationToken cancellationToken = default);
    Task<long> CountAsync(QueryOptions<T>? options = null, CancellationToken cancellationToken = default);
}
Repository Pattern (Write-Delete-Read)

Repository pattern is a sum of CQRS interfaces.

public interface IRepositoryPattern<T, TKey> : IRepositoryPattern<T, TKey, State<T>>, ICommandPattern<T, TKey>, IQueryPattern<T, TKey>, IRepositoryPattern, ICommandPattern, IQueryPattern
    where TKey : notnull
{
}

With State as TState and string as TKey

Command (Write-Delete)
public interface ICommandPattern<T> : ICommandPattern<T, string>, ICommandPattern
{
    Task<State<T>> InsertAsync(string key, T value, CancellationToken cancellationToken = default);
    Task<State<T>> UpdateAsync(string key, T value, CancellationToken cancellationToken = default);
    Task<State<T>> DeleteAsync(string key, CancellationToken cancellationToken = default);
    Task<List<BatchResult<string, State<T>>>> BatchAsync(List<BatchOperation<T, string>> operations, CancellationToken cancellationToken = default);
}
Query (Read)
public interface IQueryPattern<T> : IQueryPattern<T, string>, IQueryPattern
{
    Task<T?> GetAsync(string key, CancellationToken cancellationToken = default);
    Task<State<T>> ExistAsync(string key, CancellationToken cancellationToken = default);
    Task<IEnumerable<T>> QueryAsync(QueryOptions<T>? options = null, CancellationToken cancellationToken = default);
    Task<long> CountAsync(QueryOptions<T>? options = null, CancellationToken cancellationToken = default);
}
Repository Pattern (Write-Delete-Read)

Repository pattern is a sum of CQRS interfaces.

public interface IRepositoryPattern<T> : IRepositoryPattern<T, string>, ICommandPattern<T>, IQueryPattern<T>, IRepositoryPattern, ICommandPattern, IQueryPattern
    where TKey : notnull
{
}    

Examples

Model
public class User
{
    public string Id { get; set; }
    public string Name { get; set; }
    public string Email { get; set; }
}
Command
public class UserWriter : ICommandPattern<User, string>
{
    public Task<State<T>> DeleteAsync(string key, CancellationToken cancellationToken = default)
    {
        //delete on with DB or storage context
        throw new NotImplementedException();
    }
    public Task<State<T>> InsertAsync(string key, User value, CancellationToken cancellationToken = default)
    {
        //insert on DB or storage context
        throw new NotImplementedException();
    }
    public Task<State<T>> UpdateAsync(string key, User value, CancellationToken cancellationToken = default)
    {
        //update on DB or storage context
        throw new NotImplementedException();
    }
    public Task<List<BatchResult<string, State<T>>>> BatchAsync(List<BatchOperation<User, string>> operations, CancellationToken cancellationToken = default)
    {
        //insert, update or delete some items on DB or storage context
        throw new NotImplementedException();
    }
}
Query
public class UserReader : IQueryPattern<User, string>
{
    public Task<User?> GetAsync(string key, CancellationToken cancellationToken = default)
    {
        //get an item by key from DB or storage context
        throw new NotImplementedException();
    }
    public Task<State<T>> ExistAsync(string key, CancellationToken cancellationToken = default)
    {
        //check if an item by key exists in DB or storage context
        throw new NotImplementedException();
    }
    public Task<IEnumerable<User>> QueryAsync(QueryOptions<T>? options = null, CancellationToken cancellationToken = default)
    {
        //get a list of items by a predicate with top and skip from DB or storage context
        throw new NotImplementedException();
    }
    public Task<long> CountAsync(QueryOptions<T>? options = null, CancellationToken cancellationToken = default)
    {
        //get an items count by a predicate with top and skip from DB or storage context
        throw new NotImplementedException();
    }
}
Alltogether as repository pattern

if you don't have CQRS infrastructure (usually it's correct to use CQRS when you have minimum two infrastructures one for write and delete and at least one for read)

public class UserRepository : IRepositoryPattern<User, string>, IQueryPattern<User, string>, ICommandPattern<User, string>
{
    public Task<State<T>> DeleteAsync(string key, CancellationToken cancellationToken = default)
    {
        //delete on with DB or storage context
        throw new NotImplementedException();
    }
    public Task<State<T>> InsertAsync(string key, User value, CancellationToken cancellationToken = default)
    {
        //insert on DB or storage context
        throw new NotImplementedException();
    }
    public Task<State<T>> UpdateAsync(string key, User value, CancellationToken cancellationToken = default)
    {
        //update on DB or storage context
        throw new NotImplementedException();
    }
    public Task<List<BatchResult<string, State<T>>>> BatchAsync(List<BatchOperation<User, string>> operations, CancellationToken cancellationToken = default)
    {
        //insert, update or delete some items on DB or storage context
        throw new NotImplementedException();
    }
    public Task<User?> GetAsync(string key, CancellationToken cancellationToken = default)
    {
        //get an item by key from DB or storage context
        throw new NotImplementedException();
    }
    public Task<State<T>> ExistAsync(string key, CancellationToken cancellationToken = default)
    {
        //check if an item by key exists in DB or storage context
        throw new NotImplementedException();
    }
    public Task<IEnumerable<User>> QueryAsync(QueryOptions<T>? options = null, CancellationToken cancellationToken = default)
    {
        //get a list of items by a predicate with top and skip from DB or storage context
        throw new NotImplementedException();
    }
    public Task<long> CountAsync(QueryOptions<T>? options = null, CancellationToken cancellationToken = default)
    {
        //get an items count by a predicate with top and skip from DB or storage context
        throw new NotImplementedException();
    }
}

How to use it

In DI you install the service

services.AddRepository<User, string, UserRepository>();

And you may inject the object

IRepository<User, string> repository

Query and Command

In DI you install the services

services.AddCommand<User, string, UserWriter>();
services.AddQuery<User, string, UserReader>();

And you may inject the objects

ICommand<User, string> command
IQuery<User, string> command

Example with default key

In DI you install the services

services.AddRepository<User, UserRepository>();
services.AddCommand<User, UserWriter>();
services.AddQuery<User, UserReader>();

And you may inject the objects

IRepository<User> repository
ICommand<User> command
IQuery<User> command

Example with TState

In DI you install the services, in example we are using a Result class that is an IState<T>, instead the default integration State.

services.AddRepository<User, string, Result, UserRepository>();
services.AddCommand<User, string, Result, UserWriter>();
services.AddQuery<User, string, Result, UserReader>();

And you may inject the objects

IRepository<User, string, Result> repository
ICommand<User, string, Result> command
IQuery<User, string, Result> command

Twice or more configurations for the same repository service

Pay attention during the DI, you may install the same repository two or more times for the same model. If you want to be sure, you may start the DI with a method that checks for you. When can it happen? For instance, when you use at the same time InMemory integration with a custom integration.

services.ThrowExceptionIfARepositoryServiceIsAddedTwoOrMoreTimes();

TKey when it's not a primitive

You can use a class or record. Record is better, for example, if you want to use the Equals operator from key, with record you don't check it by the refence but by the value of the properties in the record. My key:

public class MyKey 
{
    public int Id { get; set; }
    public int Id2 { get; set; }
}

the DI

services.AddRepository<User, MyKey, Result, UserRepository>();

and you may inject (for ICommand and IQuery is the same)

IRepository<User, MyKey, Result> repository

Default TKey record

You may use the default record in repository framework namespace. For 1 value (it's not really useful I know, but I liked to create it).

new Key<int>(2);

or for 2 values

new Key<int, int>(2, 4);

or for 3 values

new Key<int, int, string>(2, 4, "312");

or for 4 values

new Key<int, int, string, Guid>(2, 4, "312", Guid.NewGuid());

or for 5 values

new Key<int, int, string, Guid, string>(2, 4, "312", Guid.NewGuid(), "3232");

the DI

services.AddRepository<User, Key<int, int>, Result, UserRepository>();

and you may inject (for ICommand and IQuery is the same)

IRepository<User, Key<int, int>, Result> repository
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (13)

Showing the top 5 NuGet packages that depend on Rystem.RepositoryFramework.Abstractions:

Package Downloads
Rystem.RepositoryFramework.Api.Server

Rystem.RepositoryFramework allows you to use correctly concepts like repository pattern, CQRS and DDD. You have interfaces for your domains, auto-generated api, auto-generated HttpClient to simplify connection "api to front-end", a functionality for auto-population in memory of your models, a functionality to simulate exceptions and waiting time from external sources to improve your implementation/business test and load test.

Rystem.RepositoryFramework.Api.Client

Rystem.RepositoryFramework allows you to use correctly concepts like repository pattern, CQRS and DDD. You have interfaces for your domains, auto-generated api, auto-generated HttpClient to simplify connection "api to front-end", a functionality for auto-population in memory of your models, a functionality to simulate exceptions and waiting time from external sources to improve your implementation/business test and load test.

Rystem.RepositoryFramework.Infrastructure.Azure.Storage.Blob

Rystem.RepositoryFramework allows you to use correctly concepts like repository pattern, CQRS and DDD. You have interfaces for your domains, auto-generated api, auto-generated HttpClient to simplify connection "api to front-end", a functionality for auto-population in memory of your models, a functionality to simulate exceptions and waiting time from external sources to improve your implementation/business test and load test.

Rystem.RepositoryFramework.Infrastructure.Azure.Storage.Table

Rystem.RepositoryFramework allows you to use correctly concepts like repository pattern, CQRS and DDD. You have interfaces for your domains, auto-generated api, auto-generated HttpClient to simplify connection "api to front-end", a functionality for auto-population in memory of your models, a functionality to simulate exceptions and waiting time from external sources to improve your implementation/business test and load test.

Rystem.RepositoryFramework.Cache

Rystem.RepositoryFramework allows you to use correctly concepts like repository pattern, CQRS and DDD. You have interfaces for your domains, auto-generated api, auto-generated HttpClient to simplify connection "api to front-end", a functionality for auto-population in memory of your models, a functionality to simulate exceptions and waiting time from external sources to improve your implementation/business test and load test.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.1.3 552 9/2/2025
9.1.2 722,864 5/29/2025
9.1.1 98,110 5/2/2025
9.0.32 186,910 4/15/2025
9.0.31 6,045 4/2/2025
9.0.30 88,998 3/26/2025
9.0.29 9,230 3/18/2025
9.0.28 413 3/17/2025
9.0.27 394 3/16/2025
9.0.26 439 3/13/2025
9.0.25 52,329 3/9/2025
9.0.23 201 3/9/2025
9.0.21 931 3/6/2025
9.0.20 19,754 3/6/2025
9.0.19 477 3/6/2025
9.0.18 481 3/4/2025
9.0.17 375 3/1/2025
9.0.16 334 3/1/2025
9.0.15 75,726 2/22/2025
9.0.14 22,767 2/18/2025
9.0.13 369 2/9/2025
9.0.12 218,187 1/13/2025
9.0.11 24,211 1/9/2025
9.0.10 307 1/9/2025
9.0.9 4,217 1/7/2025
9.0.8 12,696 1/6/2025
9.0.7 330 1/6/2025
9.0.5 19,189 12/30/2024
9.0.4 92,450 12/23/2024
9.0.3 355 12/22/2024
9.0.2 10,871 12/21/2024
9.0.1 1,381 12/21/2024
9.0.0 173,290 11/16/2024
9.0.0-rc.1 209 10/18/2024
6.2.0 219,848 10/9/2024
6.1.1 452 10/9/2024
6.1.0 48,306 9/29/2024
6.0.24 546 9/11/2024
6.0.23 340,471 7/18/2024
6.0.21 500 6/18/2024
6.0.20 728,092 6/16/2024
6.0.19 31,234 6/14/2024
6.0.18 476 6/14/2024
6.0.17 460 6/14/2024
6.0.16 50,364 6/10/2024
6.0.15 455 6/9/2024
6.0.14 94,826 5/24/2024
6.0.13 504 5/23/2024
6.0.12 450 5/23/2024
6.0.11 515 5/20/2024
6.0.9 481 5/19/2024
6.0.7 479 5/18/2024
6.0.6 491 5/10/2024
6.0.5 440 5/10/2024
6.0.4 550,460 4/3/2024
6.0.3 2,063 3/25/2024
6.0.2 378,393 3/11/2024
6.0.1 51,265 3/8/2024
6.0.0 1,172,162 11/21/2023
6.0.0-rc.6 199 10/25/2023
6.0.0-rc.5 166 10/25/2023
6.0.0-rc.4 135 10/23/2023
6.0.0-rc.3 122 10/19/2023
6.0.0-rc.2 159 10/18/2023
6.0.0-rc.1 176 10/16/2023
5.0.20 641,715 9/25/2023
5.0.19 3,411 9/10/2023
5.0.18 2,680 9/6/2023
5.0.17 2,572 9/6/2023
5.0.16 2,640 9/5/2023
5.0.15 2,625 9/5/2023
5.0.14 2,661 9/5/2023
5.0.13 2,657 9/1/2023
5.0.12 2,520 8/31/2023
5.0.11 2,565 8/30/2023
5.0.10 2,626 8/29/2023
5.0.9 2,662 8/24/2023
5.0.8 2,692 8/24/2023
5.0.7 452,174 8/23/2023
5.0.6 20,036 8/21/2023
5.0.5 6,809 8/21/2023
5.0.4 2,684 8/16/2023
5.0.3 215,232 8/2/2023
5.0.2 4,510 8/2/2023
5.0.1 14,304 8/1/2023
5.0.0 14,706 7/31/2023
4.1.26 143,541 7/20/2023
4.1.25 27,363 7/16/2023
4.1.24 400,750 6/13/2023
4.1.23 48,450 6/13/2023
4.1.22 132,436 5/30/2023
4.1.21 58,407 5/20/2023
4.1.20 407,810 4/19/2023
4.1.19 98,573 3/20/2023
4.1.18 3,122 3/20/2023
4.1.17 3,371 3/16/2023
4.1.16 3,134 3/16/2023
4.1.15 3,126 3/15/2023
4.1.14 10,806 3/9/2023
4.1.13 3,237 3/7/2023
4.1.12 3,738 2/9/2023
4.1.11 3,291 1/26/2023
4.1.10 3,585 1/22/2023
4.1.9 3,196 1/20/2023
4.1.8 3,471 1/18/2023
4.1.7 3,403 1/18/2023
4.1.6 3,497 1/17/2023
4.1.1 3,438 1/4/2023
4.1.0 3,309 1/1/2023
3.1.5 3,264 12/21/2022
3.1.4 1,642 12/21/2022
3.1.3 3,612 12/12/2022
3.1.2 3,335 12/7/2022
3.1.1 3,414 12/7/2022
3.1.0 3,389 12/1/2022
3.0.29 3,338 12/1/2022
3.0.28 4,264 12/1/2022
3.0.27 3,563 11/23/2022
3.0.25 8,074 11/23/2022
3.0.24 4,838 11/18/2022
3.0.23 4,463 11/18/2022
3.0.22 4,631 11/15/2022
3.0.21 4,658 11/14/2022
3.0.20 4,718 11/13/2022
3.0.19 5,010 11/2/2022
3.0.18 4,757 11/2/2022
3.0.17 4,818 10/29/2022
3.0.16 4,884 10/29/2022
3.0.15 1,747 10/29/2022
3.0.14 7,919 10/24/2022
3.0.13 5,000 10/24/2022
3.0.12 4,983 10/17/2022
3.0.11 4,917 10/10/2022
3.0.10 4,477 10/6/2022
3.0.9 4,397 10/6/2022
3.0.8 4,344 10/6/2022
3.0.7 4,452 10/6/2022
3.0.6 4,474 10/5/2022
3.0.5 4,345 10/5/2022
3.0.4 4,413 10/5/2022
3.0.3 4,392 10/3/2022
3.0.2 4,471 9/30/2022
3.0.1 4,420 9/29/2022
3.0.0 1,785 9/29/2022
2.0.17 4,034 9/29/2022
2.0.16 4,523 9/27/2022
2.0.15 4,626 9/27/2022
2.0.14 4,546 9/26/2022
2.0.13 4,484 9/26/2022
2.0.12 4,445 9/26/2022
2.0.11 4,408 9/25/2022
2.0.10 4,605 9/25/2022
2.0.9 4,486 9/22/2022
2.0.8 4,392 9/22/2022
2.0.7 1,806 9/22/2022
2.0.6 4,402 9/20/2022
2.0.5 4,642 9/20/2022
2.0.4 4,497 9/20/2022
2.0.2 4,513 9/20/2022
2.0.1 4,738 9/13/2022
2.0.0 4,598 8/19/2022
1.1.24 4,618 7/30/2022
1.1.23 4,572 7/29/2022
1.1.22 4,337 7/29/2022
1.1.21 4,781 7/29/2022
1.1.20 4,542 7/29/2022
1.1.19 4,566 7/27/2022
1.1.17 4,574 7/27/2022
1.1.16 4,570 7/26/2022
1.1.15 4,613 7/25/2022
1.1.14 4,564 7/25/2022
1.1.13 4,468 7/22/2022
1.1.12 4,471 7/19/2022
1.1.11 4,540 7/19/2022
1.1.10 4,559 7/19/2022
1.1.9 4,550 7/19/2022
1.1.8 4,635 7/18/2022
1.1.7 4,480 7/18/2022
1.1.6 4,570 7/18/2022
1.1.5 4,528 7/17/2022
1.1.4 1,774 7/17/2022
1.1.3 7,176 7/17/2022
1.1.2 4,616 7/17/2022
1.1.1 1,815 7/17/2022
1.1.0 4,553 7/17/2022
1.0.2 4,528 7/15/2022
1.0.1 3,169 7/15/2022
1.0.0 5,784 7/8/2022
0.10.7 4,538 7/7/2022
0.10.6 1,866 7/7/2022
0.10.3 2,338 7/7/2022
0.10.2 6,034 7/2/2022
0.10.1 4,539 7/1/2022
0.10.0 4,329 7/1/2022
0.9.10 5,708 6/20/2022
0.9.9 4,611 6/11/2022
0.9.8 1,795 6/10/2022
0.9.7 4,474 6/9/2022
0.9.6 4,492 6/5/2022
0.9.5 3,048 6/3/2022
0.9.3 4,378 6/3/2022
0.9.2 2,612 5/31/2022
0.9.1 2,573 5/31/2022
0.9.0 2,550 5/31/2022
0.8.3-beta.1 206 5/31/2022
0.8.2 1,859 5/30/2022
0.8.1 1,867 5/29/2022