Prodest.AuditNET 7.0.5

This package has a SemVer 2.0.0 package version: 7.0.5+20231101074224.
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 Prodest.AuditNET --version 7.0.5
                    
NuGet\Install-Package Prodest.AuditNET -Version 7.0.5
                    
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="Prodest.AuditNET" Version="7.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Prodest.AuditNET" Version="7.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Prodest.AuditNET" />
                    
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 Prodest.AuditNET --version 7.0.5
                    
#r "nuget: Prodest.AuditNET, 7.0.5"
                    
#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 Prodest.AuditNET@7.0.5
                    
#: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=Prodest.AuditNET&version=7.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Prodest.AuditNET&version=7.0.5
                    
Install as a Cake Tool

Prodest.AuditNET

Sobre

Pacote com a configuração necessária para realizar a auditoria de contextos do entity framework.

Como usar?

var builder = WebApplication.CreateBuilder(Environment.GetCommandLineArgs());

builder.Services
    .AddDbContext<WeatherDbContext>(
        (sp, options) => options
            .AddInterceptors(new AuditSaveChangesInterceptor())
            .UseSqlServer(
                sp.GetRequiredService<IConfiguration>()
                    .GetConnectionString("AuditLogConnection")
            )
    );

builder.Services
    .ConfigureSqlAudit();

var app = builder.Build();

await app.RunAsync();

Existem duas formas de habilitar a auditoria, a primeira é via a extensão IServiceCollection.AddDbContext, vide exemplo acima, já a segunda forma é adicionando o interceptor .AddInterceptors(new AuditSaveChangesInterceptor()) na sobrecarga do método OnConfiguring de uma classe de contexto que é derivada da classe DbContext:

internal sealed class WeatherDbContext : DbContext
{
    private readonly IConfiguration _configuration;

    public WeatherDbContext(IConfiguration configuration)
    {
        _configuration = configuration;
    }

    public DbSet<WeatherForecast> Forecasts { get; set; } = null!;

    /// <inheritdoc />
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.AddInterceptors(new AuditSaveChangesInterceptor())
            .UseSqlServer(_configuration.GetConnectionString("DefaultConnection"));
    }

    /// <inheritdoc />
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder
            .Entity<WeatherForecast>(e =>
            {
                e.ToTable("WeatherForecast", "dbo");

                e.Property(x => x.ForecastId)
                    .ValueGeneratedOnAdd()
                    .HasColumnType("uniqueidentifier");

                e.Property(x => x.Date)
                    .IsRequired();

                e.Property(x => x.TemperatureC)
                    .IsRequired();

                e.Property(x => x.TemperatureF);

                e.Property(x => x.Summary)
                    .HasMaxLength(50)
                    .IsRequired();

                e.HasKey(y => y.ForecastId);
            })
            .HasAnnotation("Relational:Collation", "Latin1_General_CI_AS")
            .HasDefaultSchema("dbo");
    }
}

Após isso é necessário chamar a extensão que completa a configuração de auditoria na classe de startup:

builder.Services
    .ConfigureSqlAudit();
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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.  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.  net10.0 was computed.  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.

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
Loading failed