-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
89 changed files
with
75,163 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
Console.WriteLine("Hello, World!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Infoware.EntityFrameworkCore.AuditEntity\Infoware.EntityFrameworkCore.AuditEntity.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Infoware.EntityFrameworkCore.AuditEntity; | ||
using Infoware.EntityFrameworkCore.AuditEntity.Extensions; | ||
using Infoware.SensitiveDataLogger.JsonSerializer; | ||
using Microsoft.EntityFrameworkCore; | ||
using Test.Models; | ||
|
||
namespace Test | ||
{ | ||
public class BlogContext : DbContext | ||
{ | ||
public const string DEFAULT_SCHEMA = "blogs"; | ||
private readonly ILogJsonSerializer _logJsonSerializer; | ||
|
||
public DbSet<Blog> Blogs => Set<Blog>(); | ||
public DbSet<BlogAudit> BlogAudits => Set<BlogAudit>(); | ||
|
||
public BlogContext(DbContextOptions options, ILogJsonSerializer logJsonSerializer) : base(options) | ||
{ | ||
_logJsonSerializer = logJsonSerializer; | ||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
base.OnModelCreating(modelBuilder); | ||
} | ||
|
||
public override int SaveChanges() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = default) | ||
{ | ||
return await this.SaveWithAuditsAsync(_logJsonSerializer, | ||
FactoryBase, | ||
(cancellationToken) => base.SaveChangesAsync(cancellationToken), | ||
cancellationToken); | ||
} | ||
|
||
internal static Task<IBaseAudit?> FactoryBase(Type source) | ||
{ | ||
var result = (IBaseAudit?)Activator.CreateInstance(source); | ||
return Task.FromResult(result); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using System.Reflection; | ||
using Test; | ||
|
||
namespace WebApplication1 | ||
{ | ||
public static class ServiceCollectionExtensions | ||
{ | ||
public static IServiceCollection AddCustomDbContext(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.AddDbContext<BlogContext>( | ||
options => | ||
{ | ||
options.UseSqlServer(configuration["ConnectionStrings:DocumentosElectronicosSRI"], sqlOptions => | ||
{ | ||
sqlOptions.MigrationsAssembly(typeof(Program).GetTypeInfo().Assembly.GetName().Name); | ||
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), null); | ||
}); | ||
}, | ||
ServiceLifetime.Singleton //Showing explicitly that the DbContext is shared across the HTTP request scope (graph of objects started in the HTTP request) | ||
); | ||
return services; | ||
} | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
WebApplication1/Migrations/20231105041501_InitialCreate.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.