Flowsy.Db.Sql
0.2.0
See the version list below for details.
dotnet add package Flowsy.Db.Sql --version 0.2.0
NuGet\Install-Package Flowsy.Db.Sql -Version 0.2.0
<PackageReference Include="Flowsy.Db.Sql" Version="0.2.0" />
paket add Flowsy.Db.Sql --version 0.2.0
#r "nuget: Flowsy.Db.Sql, 0.2.0"
// Install Flowsy.Db.Sql as a Cake Addin #addin nuget:?package=Flowsy.Db.Sql&version=0.2.0 // Install Flowsy.Db.Sql as a Cake Tool #tool nuget:?package=Flowsy.Db.Sql&version=0.2.0
Flowsy Db Sql
This package includes implementations for interfaces defined in Flows.Db.Abstractions oriented to SQL databases.
Connection Factory
The class DbConnectionFactory implements the interface IDbConnectionFactory to create IDbConnection objects from a list of registered configurations identified by unique keys.
Unit Of Work
The class DbUnitOfWork implements the interface IUnitOfWork to create IDbTransaction objects from a given IDbConnection.
For example, to create an invoice, we may need to create two kinds of entities:
- Invoice
- InvoiceId
- CustomerId
- CreateDate
- Total
- Taxes
- GrandTotal
- InvoiceItem
- InvoiceItemId
- InvoiceId
- ProductId
- Quantity
- Amount
A way of completing such operation from an application-level command handler could be:
public interface ISalesUnitOfWork : IUnitOfWork
{
IInvoiceRepository InvoiceRepository { get; }
IInvoiceItemRepository InvoiceItemRepository { get; }
}
public class SalesUnitOfWork : DbUnitOfWork, ISalesUnitOfWork
{
private readonly IInvoiceRepository? _invoiceRepository;
private readonly IInvoiceItemRepository? _invoiceItemRepository;
public SalesUnitOfWork(IDbConnection connection) : base(connection)
{
}
public IInvoiceRepository InvoiceRepository
=> _invoiceRepository ??= new InvoiceRepository(Transaction);
public IInvoiceItemRepository InvoiceItemRepository
=> _invoiceItemRepository ??= new InvoiceItemRepository(Transaction);
}
public class CreateInvoiceCommandHandler
{
private readonly IUnitOfWorkFactory _unitOfWorkFactory;
public CreateInvoiceCommandHandler(IUnitOfWorkFactory unitOfWorkFactory)
{
_unitOfWorkFactory = unitOfWorkFactory;
}
public async Task<CreateInvoiceCommandResult> HandleAsync(CreateInvoiceCommand command, CancellationToken cancellationToken)
{
// Begin operation
// IUnitOfWork inherits from IDisposable and IAsyncDisposable, if any exception is thrown, the current operation shall be rolled back
await using var unitOfWork = _unitOfWorkFactory.Create<ISalesUnitOfWork>();
var invoice = new Invoice();
// Populate invoice object from properties of command object
// Create the Invoice entity
var invoiceId = await unitOfWork.InvoiceRepository.CreateAsync(invoice, cancellationToken);
// Create all the InvoiceItem entities
foreach (var item in command.Items)
{
var invoiceItem = new InvoiceItem();
// Populate invoiceItem object from properties of item object
// Create each InvoiceItem entity
await unitOfWork.InvoiceItemRepository.CreateAsync(invoiceItem, cancellationToken);
}
// Commit the current operation
await unitOfWork.SaveAsync(cancellationToken);
// Return the result of the operation
return new CreateInvoiceCommandResult
{
InvoiceId = invoiceId
};
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Dapper (>= 2.1.15)
- Flowsy.Db.Abstractions (>= 0.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Flowsy.Db.Sql:
Package | Downloads |
---|---|
Flowsy.Db.Cli
Utility classes to create an interactive command line interface tool to perform database management tasks. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.2.0 | 139 | 5/26/2024 |
4.1.0 | 117 | 5/25/2024 |
4.0.1 | 133 | 2/25/2024 |
4.0.0 | 120 | 2/10/2024 |
3.0.1 | 140 | 2/3/2024 |
3.0.0 | 109 | 2/3/2024 |
2.0.1 | 112 | 1/28/2024 |
2.0.0 | 100 | 1/27/2024 |
1.3.0 | 100 | 1/27/2024 |
1.2.0 | 130 | 1/15/2024 |
1.1.0 | 147 | 1/6/2024 |
1.0.0 | 200 | 12/11/2023 |
0.8.0 | 151 | 11/29/2023 |
0.7.0 | 214 | 11/27/2023 |
0.6.1 | 171 | 11/27/2023 |
0.6.0 | 168 | 11/27/2023 |
0.5.1 | 145 | 11/26/2023 |
0.5.0 | 124 | 11/26/2023 |
0.4.3 | 140 | 11/10/2023 |
0.4.2 | 127 | 11/10/2023 |
0.4.1 | 130 | 11/10/2023 |
0.4.0 | 128 | 11/10/2023 |
0.3.0 | 132 | 11/10/2023 |
0.2.0 | 142 | 10/24/2023 |
0.1.0 | 132 | 10/24/2023 |