Flowsy.Db.Sql 0.2.0

There is a newer version of this package available.
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
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="Flowsy.Db.Sql" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Flowsy.Db.Sql --version 0.2.0
#r "nuget: Flowsy.Db.Sql, 0.2.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.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.1 87 2/25/2024
4.0.0 90 2/10/2024
3.0.1 74 2/3/2024
3.0.0 80 2/3/2024
2.0.1 82 1/28/2024
2.0.0 75 1/27/2024
1.3.0 72 1/27/2024
1.2.0 99 1/15/2024
1.1.0 118 1/6/2024
1.0.0 147 12/11/2023
0.8.0 109 11/29/2023
0.7.0 143 11/27/2023
0.6.1 129 11/27/2023
0.6.0 132 11/27/2023
0.5.1 100 11/26/2023
0.5.0 88 11/26/2023
0.4.3 113 11/10/2023
0.4.2 85 11/10/2023
0.4.1 85 11/10/2023
0.4.0 100 11/10/2023
0.3.0 87 11/10/2023
0.2.0 113 10/24/2023
0.1.0 107 10/24/2023