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" />
<PackageReference Include="Repoframework.Repository" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=Repoframework.Repository&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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
- 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);
}
- 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);
}
}
- 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();
}
- 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.
- Faça o build da aplicação e rode normalmente.
Autores
| Product | Versions 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.
-
net10.0
- Dapper (>= 2.1.66)
- Microsoft.Data.SqlClient (>= 6.1.3)
- Microsoft.Extensions.Configuration (>= 10.0.2)
- Microsoft.Extensions.Options (>= 10.0.2)
- MongoDB.Driver (>= 3.6.0)
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 |
|---|