43 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using Microsoft.EntityFrameworkCore;
 | |
| 
 | |
| #region AuditContext
 | |
| public class AuditContext : DbContext
 | |
| {
 | |
|     private readonly string _connectionString;
 | |
| 
 | |
|     public AuditContext(string connectionString)
 | |
|     {
 | |
|         _connectionString = connectionString;
 | |
|     }
 | |
| 
 | |
|     //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 | |
|     //    => optionsBuilder.Usesq(_connectionString);
 | |
| 
 | |
|     public DbSet<SaveChangesAudit> SaveChangesAudits { get; set; }
 | |
| }
 | |
| 
 | |
| 
 | |
| public class SaveChangesAudit
 | |
| {
 | |
|     public int Id { get; set; }
 | |
|     public Guid AuditId { get; set; }
 | |
|     public DateTime StartTime { get; set; }
 | |
|     public DateTime EndTime { get; set; }
 | |
|     public bool Succeeded { get; set; }
 | |
|     public string ErrorMessage { get; set; }
 | |
| 
 | |
|     public ICollection<EntityAudit> Entities { get; } = new List<EntityAudit>();
 | |
| }
 | |
| 
 | |
| public class EntityAudit
 | |
| {
 | |
|     public int Id { get; set; }
 | |
|     public EntityState State { get; set; }
 | |
|     public string AuditMessage { get; set; }
 | |
| 
 | |
|     public SaveChangesAudit SaveChangesAudit { get; set; }
 | |
| }
 | |
| 
 | |
| #endregion |