AuditedDbContextBuilderExtensions.WithAuditedDbContext<TContext>(DbContextBuilder<TContext>, Action<AuditedDbContextConfigurator>, ServiceLifetime) Method
Allows you to configure the main (business object) and additional (audit history) DbContext
objects in WinForms applications with the Audit Trail Module.
Namespace: DevExpress.ExpressApp.ApplicationBuilder
Assembly: DevExpress.ExpressApp.AuditTrail.EFCore.v24.2.dll
NuGet Package: DevExpress.ExpressApp.AuditTrail.EFCore
#Declaration
public static IObjectSpaceProviderBuilder<TContext> WithAuditedDbContext<TContext>(
this DbContextBuilder<TContext> dbContextBuilder,
Action<AuditedDbContextConfigurator> configureContexts,
ServiceLifetime dbContextFactoryServiceLifetime = ServiceLifetime.Scoped
)
where TContext : IXafApplicationBuilder<TContext>, IAccessor<IServiceCollection>
#Parameters
Name | Type | Description |
---|---|---|
db |
Db |
Allows you to configure |
configure |
Action<Audited |
A delegate that configures |
#Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
db |
Service |
Scoped | A Service |
#Type Parameters
Name | Description |
---|---|
TContext | The IWin |
#Returns
Type | Description |
---|---|
IObject |
Allows you to register and configure Object Space Providers in your application, and chain further provider registrations. |
#Remarks
The following example demonstrates how to use this method:
File: MySolution.Win\Startup.cs.
using DevExpress.ExpressApp.ApplicationBuilder;
using DevExpress.ExpressApp.Win.ApplicationBuilder;
// ...
public class ApplicationBuilder : IDesignTimeApplicationFactory {
public static WinApplication BuildApplication(string connectionString) {
var builder = WinApplication.CreateBuilder();
builder.UseApplication<MySolutionWindowsFormsApplication>();
builder.ObjectSpaceProviders
.AddSecuredEFCore()
.WithAuditedDbContext(contexts => {
contexts.Configure<MySolutionDbContext, AuditingDbContext>(
(application, businessObjectDbContextOptions) => {
// ...
},
(application, auditHistoryDbContextOptions) => {
// ...
},
options => {
// ...
});
});
}
// ...
}