MVFC.SQLCraft
1.1.1
dotnet add package MVFC.SQLCraft --version 1.1.1
NuGet\Install-Package MVFC.SQLCraft -Version 1.1.1
<PackageReference Include="MVFC.SQLCraft" Version="1.1.1" />
<PackageVersion Include="MVFC.SQLCraft" Version="1.1.1" />
<PackageReference Include="MVFC.SQLCraft" />
paket add MVFC.SQLCraft --version 1.1.1
#r "nuget: MVFC.SQLCraft, 1.1.1"
#:package MVFC.SQLCraft@1.1.1
#addin nuget:?package=MVFC.SQLCraft&version=1.1.1
#tool nuget:?package=MVFC.SQLCraft&version=1.1.1
MVFC.SQLCraft
Biblioteca base para abstração e manipulação de bancos de dados SQL no .NET 9.0.
Fornece interfaces, utilitários e integração com SqlKata.
Instalação
dotnet add package MVFC.SQLCraft
Recursos
- Abstração de drivers SQL
- Integração com múltiplos bancos
- Factory para criação de conexões
Principais Métodos
// Retornar só um objeto
T? QueryFirstOrDefault<T>(Query query, IDbTransaction? tx = null);
Task<T?> QueryFirstOrDefaultAsync<T>(Query query, IDbTransaction? tx = null, CancellationToken ct = default);
// Retornar múltiplos objetos
IEnumerable<T> Query<T>(Query query, IDbTransaction? tx = null);
Task<IEnumerable<T>> QueryAsync<T>(Query query, IDbTransaction? tx = null, CancellationToken ct = default);
// Executar uma query e retornar linhas afetadas
int Execute(Query query, IDbTransaction? tx = null);
Task<int> ExecuteAsync(Query query, IDbTransaction? tx = null, CancellationToken ct = default);
// Executar uma query bruta e retornar linhas afetadas
int Execute(string sql, IDbTransaction? tx = null);
Task<int> ExecuteAsync(string sql, IDbTransaction? tx = null, CancellationToken ct = default);
// Realizar uma transação
void ExecuteInTransaction(Action<SQLCraftDriver, IDbTransaction> action, IsolationLevel isolation = IsolationLevel.ReadCommitted);
Task ExecuteInTransactionAsync(Func<SQLCraftDriver, IDbTransaction, CancellationToken, Task> action, IsolationLevel isolation = IsolationLevel.ReadCommitted, CancellationToken ct = default);
Exemplo de transação
await driver.ExecuteInTransactionAsync(async (x, t, ct) => {
await x.ExecuteAsync(new Query("Person")
.AsInsert(new
{
Name = "Bob"
}), t, ct);
var sel = new Query("Person")
.Select("Id", "Name")
.Where("Name", "Bob");
var p = await x.QueryFirstOrDefaultAsync<Person>(sel, t, ct);
Assert.NotNull(p);
var upd = new Query("Person")
.Where("Id", p!.Id)
.AsUpdate(new
{
Name = "Robert"
});
var upaff = await x.ExecuteAsync(upd, t, ct);
Assert.Equal(1, upaff);
var sel2 = new Query("Person")
.Select("Id", "Name")
.Where("Id", p.Id);
var p2 = await x.QueryFirstOrDefaultAsync<Person>(sel2, t, ct);
Assert.NotNull(p2);
Assert.Equal("Robert", p2!.Name);
});
Licença
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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 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. |
-
net10.0
- sqlkata (>= 4.0.1)
- sqlkata.execution (>= 4.0.1)
-
net9.0
- sqlkata (>= 4.0.1)
- sqlkata.execution (>= 4.0.1)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on MVFC.SQLCraft:
| Package | Downloads |
|---|---|
|
MVFC.SQLCraft.Mysql
MVFC.SQLCraft.Mysql: Extensão para acesso MySQL usando MVFC.SQLCraft. Integração simplificada e segura para bancos MySQL em .NET 9. |
|
|
MVFC.SQLCraft.PostgreSql
MVFC.SQLCraft.PostgreSql: Extensão para acesso PostgreSQL usando MVFC.SQLCraft. Fornece integração simplificada e segura para bancos PostgreSQL em .NET 9. |
|
|
MVFC.SQLCraft.SQLite
MVFC.SQLCraft.SQLite: Extensão para acesso SQLite usando MVFC.SQLCraft. Integração simplificada e segura para bancos SQLite em .NET 9. |
|
|
MVFC.SQLCraft.MsSQL
MVFC.SQLCraft.MsSQL: Extensão para acesso Microsoft SQL Server usando MVFC.SQLCraft. Integração simplificada e segura para bancos SQL Server em .NET 9. |
|
|
MVFC.SQLCraft.Firebird
MVFC.SQLCraft.Firebird: Extensão para acesso Firebird usando MVFC.SQLCraft. Integração simplificada e segura para bancos Firebird em .NET 9. |
GitHub repositories
This package is not used by any popular GitHub repositories.