Replies: 1 comment 1 reply
-
I couldn't reproduce the issue. I attempted to audit a DbContext by inserting a new entity with an auto-generated ID and configured a Polly strategy as follows: var fallbackDataProvider = new FileDataProvider(c => c.Directory(@"c:\temp\logs"));
var sqlDataProvider = new SqlDataProvider(s => s
.ConnectionString("data source=localhost;initial catalog=issue674;integrated security=true;Encrypt=False;")
.TableName("Logs")
.IdColumnName("Id")
.CustomColumn("TableName", ev => ((AuditEventEntityFramework)ev).EntityFrameworkEvent.Entries[0].Table)
.JsonColumnName("EventJson"));
Audit.Core.Configuration.Setup()
.UsePolly(p => p
.DataProvider(sqlDataProvider)
.WithResilience(r => r
.AddFallback(new()
{
ShouldHandle = new PredicateBuilder().Handle<Exception>(),
FallbackAction = a => a.FallbackToDataProvider(fallbackDataProvider)
}))); I see the correct primary key in both cases, (SQL or the file log) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've added Polly to my project to have some sort of fallback, but I've noticed this way the entry did not contain the freshly created Id from the databae (MS SQL) , instead an overflow/uninitialized value appeared:
{"Entry":{"Table":"X","Name":"XY","PrimaryKey":{"Id":-2147482645},"Action":"Insert","ColumnValues":...
"Entries":[{"Table":"X","Name":"XY","PrimaryKey":{"Id":-2147482645},"Action":"Insert","ColumnValues":{"Id":-2147482645,"Name":"1v"},"Valid":true}],"Result":0,"Success":false}}
According to this, the PrimaryKey value should be OK:
#646
Chaning back to the original
Audit.Core.Configuration.Setup().UseCustomProvider(sqlDataProvider);
version, the new Id appears fine.
Any suggestions, is this a known behavior?
Beta Was this translation helpful? Give feedback.
All reactions