SharpCrud 1.0.0

dotnet add package SharpCrud --version 1.0.0
                    
NuGet\Install-Package SharpCrud -Version 1.0.0
                    
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="SharpCrud" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharpCrud" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SharpCrud" />
                    
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 SharpCrud --version 1.0.0
                    
#r "nuget: SharpCrud, 1.0.0"
                    
#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.
#addin nuget:?package=SharpCrud&version=1.0.0
                    
Install SharpCrud as a Cake Addin
#tool nuget:?package=SharpCrud&version=1.0.0
                    
Install SharpCrud as a Cake Tool

<img src="logo.png" alt="Logo" width="400" style="display:block; margin:auto;"> <hr>

SharpCrud

SharpCrud is a .NET library designed to standardize CRUD (Create, Read, Update, Delete) operations through interfaces, promoting clean architecture and separation of concerns. It provides both synchronous and asynchronous interfaces for single and bulk operations, making it easy to implement consistent data access patterns.

Features

  • Action Interfaces: Base interfaces for individual CRUD operations.
    • ICreate, IRead, IUpdate, IDelete
    • Async variants (ICreateAsync, IReadAsync, etc.).
    • Bulk operation support (ICreateMany, IReadMany, etc.) and their async counterparts.
  • CRUD Aggregates: Unified interfaces combining actions:
    • ICrud: Standard CRUD operations.
    • ICrudAsync: Async CRUD operations.
    • ICrudMany and ICrudManyAsync: Bulk operations with sync/async support.
  • Flexibility: Decouple your business logic from data access implementations.
  • Async Ready: Built for modern applications with Task-based async patterns.

Installation

dotnet add package SharpCrud

Usage

Implementing Action Interfaces

// Example: Sync Create operation
public class UserCreator : ICreate<User, UserInput>
{
    public User Create(UserInput input)
    {
        // Your implementation here
    }
}

// Example: Async Read operation
public class UserReader : IReadAsync<User, UserQuery>
{
    public async Task<User?> ReadAsync(UserQuery query)
    {
        // Your async implementation here
    }
}

Using CRUD Aggregates

// Implement ICrud for a User entity
public class UserCrud : ICrud<User, UserInput, User, int, User, int, UserInput, int>
{
    public User Create(UserInput input) => /* ... */;
    public User? Read(int id) => /* ... */;
    public User Update(int id, UserInput input) => /* ... */;
    public void Delete(int id) => /* ... */;
}

// Async version
public class UserCrudAsync : ICrudAsync<User, UserInput, User, int, User, int, UserInput, int>
{
    public Task<User> CreateAsync(UserInput input) => /* ... */;
    public Task<User?> ReadAsync(int id) => /* ... */;
    public Task<User> UpdateAsync(int id, UserInput input) => /* ... */;
    public Task DeleteAsync(int id) => /* ... */;
}

Interfaces Overview

Action Interfaces

Interface Description
ICreate<TEntity, TInput> Creates an entity from input.
IRead<TEntity, TQuery> Retrieves a single entity by query.
IUpdate<TEntity, TQuery, TInput> Updates an entity by query and input.
IDelete<TQuery> Deletes an entity by query.

Async versions append Async to the name (e.g., CreateAsync(...), ICreateAsync). Bulk interfaces (e.g., CreateMany(...),ICreateMany). for Async bulk interfaces append ManyAsync to the name.

CRUD Aggregates

  • ICrud: Combines ICreate, IRead, IUpdate, IDelete.
  • ICrudAsync: Async variant of ICrud.
  • ICrudMany: Bulk operations (CreateMany, ReadMany, etc.).
  • ICrudManyAsync: Async bulk operations.

Contributing

Contributions are welcome! Feel free to submit issues, feature requests, or pull requests to the development branch. Please follow the project's coding standards and include tests where applicable.

License

Licensed under the Apache License 2.0. See LICENSE for details.

Author

Mohammad Ayaad
GitHub: @mohammadayaad

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 98 2 months ago