Persilsoft.Transactions 1.0.8

dotnet add package Persilsoft.Transactions --version 1.0.8
                    
NuGet\Install-Package Persilsoft.Transactions -Version 1.0.8
                    
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="Persilsoft.Transactions" Version="1.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Persilsoft.Transactions" Version="1.0.8" />
                    
Directory.Packages.props
<PackageReference Include="Persilsoft.Transactions" />
                    
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 Persilsoft.Transactions --version 1.0.8
                    
#r "nuget: Persilsoft.Transactions, 1.0.8"
                    
#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.
#addin nuget:?package=Persilsoft.Transactions&version=1.0.8
                    
Install Persilsoft.Transactions as a Cake Addin
#tool nuget:?package=Persilsoft.Transactions&version=1.0.8
                    
Install Persilsoft.Transactions as a Cake Tool

Persilsoft.Transactions

Provides a service for transaccion management.


Example

First, you need to register the required service.

using Persilsoft.Transactions;

builder.Services.AddTransactionScopeServices();
// builder.Services.AddTransactionEFService<MyDbContext>();    -- For SQLite provider

Finally, you can use the service.

using Persilsoft.Transactions.Abstractions;

app.MapPost("/person/register", async (MyDbContext context, ITransactionService transactionService) =>
{
    try
    {
        transactionService.BeginTransaction();
        context.Persons.Add(new Person
        {
            FirstName = "Juan",
            LastName = "Pérez"
        });
        await context.SaveChangesAsync();
        var otherOperationIsSuccess = await Task.FromResult(false);
        if (!otherOperationIsSuccess)
        {
            throw new Exception("An error has ocurred.");
        }

        transactionService.CommitTransaction();

        return Results.Ok("Operation Success");
    }
    catch (Exception ex)
    {
        transactionService.RollbackTransaction();
        return Results.Problem(detail: ex.Message);
    }
})
.WithTags("Person");

Note:
You can use constructor injection.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Persilsoft.Transactions:

Package Downloads
Persilsoft.Membership.AspNetIdentity.SqlServer

Contains the configuration and DbContext for AspNetIdentity projects with Sql Server provider

Persilsoft.Membership.AspNetIdentity.SQLite

Contains the configuration and DbContext for AspNetIdentity projects with SQLite provider

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.8 0 5 hours ago
1.0.7 1,459 6 months ago
1.0.6 1,095 9 months ago
1.0.5 1,111 5/22/2024
1.0.4 829 4/13/2024
1.0.3 111 4/11/2024
1.0.2 118 4/7/2024
1.0.1 112 4/7/2024
1.0.0 108 4/7/2024