Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fluent Api Configuration for SqlServer #670

Closed
srzsantiago opened this issue Jun 17, 2024 · 3 comments
Closed

Fluent Api Configuration for SqlServer #670

srzsantiago opened this issue Jun 17, 2024 · 3 comments
Assignees
Labels

Comments

@srzsantiago
Copy link

Describe the bug
After upgrading from Audit.Net.SqlServer version 24.0.1 to 25.0.x, the fluent API configuration began failing. The issue specifically occurs with the dynamic schema configuration, where the AuditEventWebApi consistently results in being null. I've attempted alternative approaches, such as using SqlDataProvider, but the problem persists—the event is always null. Despite searching for breaking changes between versions 24.x and 25.x, I haven't found any relevant information. It's essential for me to use a dynamic schema since the database contains multiple schemas. Below is my configuration with the fluent API:

Audit.Core.Configuration.Setup()
    .UseSqlServer(config => config
        .ConnectionString(c => GetAuditConnectionString((AuditEventWebApi)c))
        .Schema(s => GetAuditTableSchema((AuditEventWebApi)s))
        .TableName(t => GetAuditTableName((AuditEventWebApi)t))
        .IdColumnName("IdColumn")
        .JsonColumnName("JsonColumn")
    );

In this configuration, the variable s within the schema method is always null.

To Reproduce
Trigger a Web API Action.

Expected Behavior
The AuditEventWebApi variable s should be populated with an AuditApiAction containing all the information about the Web API action.

Libraries
Audit.NET: 25.0.4
Audit.NET.SqlServer: 25.0.4
Audit.WebApi.Core: 25.0.4

Target .NET Framework
.NET 8.0

@srzsantiago srzsantiago changed the title Fluent Api Configuration for SQL Fluent Api Configuration for SqlServer Jun 17, 2024
@thepirat000 thepirat000 self-assigned this Jun 17, 2024
@thepirat000
Copy link
Owner

It's a bug in the condition on the following line:

return Schema.GetDefault() != null
? string.Format("[{0}].[{1}]", Schema.GetValue(auditEvent), TableName.GetValue(auditEvent))
: string.Format("[{0}]", TableName.GetValue(auditEvent));

It should be:

            return Schema.GetValue(auditEvent) != null  
                ? ...
                : ...;

I will be fixing this soon and creating a new version.

@thepirat000
Copy link
Owner

Fixed on version 25.0.5, please upgrade your references and re-test

@srzsantiago
Copy link
Author

I upgraded and re-tested it. It all works! Thank you very much for the fast reaction and implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants