Repoframework.Repository 1.0.1

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Repoframework.Repository --version 1.0.1
                    
NuGet\Install-Package Repoframework.Repository -Version 1.0.1
                    
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="Repoframework.Repository" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Repoframework.Repository" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Repoframework.Repository" />
                    
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 Repoframework.Repository --version 1.0.1
                    
#r "nuget: Repoframework.Repository, 1.0.1"
                    
#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 Repoframework.Repository@1.0.1
                    
#: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=Repoframework.Repository&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Repoframework.Repository&version=1.0.1
                    
Install as a Cake Tool

RepoFramework

O RepoFramework foi criado para facilitar a utilização de CRUDs e com ele você não precisa fazer a implementação manualmente.

Funcionalidades

  • Integração com SqlServer com Dapper
  • Implementação de Insert
  • Implementação de GetAll
  • Implementação de GetByIdentifier
  • Implementação de Update
  • Implementação de Delete

Stack utilizada

Back-end: .NET 10, Dapper, SqlClient

Uso/Exemplos

  1. Recomendamos criar uma interface para utilizar os métodos CRUD no seu repository.
public interface IRepositoryUser
{
    Task Create(object formatObject, string sql);
    Task<IEnumerable<TReturn>> GetAll<TReturn>(string sql);
}
  1. Criar um Repository para sua entidade implementando a interface que você gerou.
public class RepositoryUser : IRepositoryUser
{
    private readonly IRepositoryBase _repositoryBase;

    public RepositoryUser(IRepositoryBase repositoryBase)
    {
        _repositoryBase = repositoryBase;
    }

    public async Task Create(object formatObject, string sql)
    {
        await _repositoryBase.Create(formatObject, sql);
    }

    public async Task<IEnumerable<TReturn>> GetAll<TReturn>(string sql)
    {
        return await _repositoryBase.GetAll<TReturn>(sql);
    }
}
  1. Fazer a Injeção de Dependência do seu repository dentro da sua camada de utilização - (Para fins de demonstração, foi utilizado na Controller, porém não é recomendado essa prática em cenários reais).
private readonly RepositoryUser _repositoryBase;
public UserController(RepositoryUser repositoryBase)
{
    _repositoryBase = repositoryBase;
}

[HttpGet]
public async Task<ActionResult> Get()
{
    var sql = @"SELECT Id, Name, Age FROM Users";
    var users = await _repositoryBase.GetAll<Users>(sql);
    if (users is not null)
        return Ok(users);
    return NoContent();
}

[HttpPost]
public async Task<ActionResult> Post([FromBody] Users req)
{
    var user = new Users(req.Name, req.Age);
    var sql = @"INSERT INTO Users(Id, Name, Age) VALUES (@id, @name, @age)";
    await _repositoryBase.Create(new { id = user.Id, name = user.Name, age = user.Age }, sql);
    return Created();
}
  1. Após isso, faça o registro das devidas DIs dentro de sua aplicação.
builder.Services.Configure<DatabaseOptions>(builder.Configuration.GetSection("ConnectionStrings"));
builder.Services.AddSingleton<IConfigurationDB, DatabaseSqlServer>();
builder.Services.AddSingleton(typeof(IRepositoryBase), typeof(RepositoryBase));
builder.Services.AddSingleton<RepositoryUser>();
Observação: No registro da dependência, é utilizado uma classe de modelo para buscar a sua conexão do banco, onde dentro dela contém a propriedade - ConnectionString, dentro da sua sessão, deve estar com o mesmo nome para identificação da connection string.
  1. Faça o build da aplicação e rode normalmente.

Autores

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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

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