-
-
Notifications
You must be signed in to change notification settings - Fork 0
easyextensionsentityframeworkcoredatabase AuditedDbContext
A DbContext instance represents a session with the database and can be used to query and save instances of your entities. DbContext is a combination of the Unit Of Work and Repository patterns. This version of DbContext is designed for automated auditing of entities.
flowchart LR
classDef interfaceStyle stroke-dasharray: 5 5;
classDef abstractStyle stroke-width:4px
subgraph EasyExtensions.EntityFrameworkCore.Database
EasyExtensions.EntityFrameworkCore.Database.AuditedDbContext[[AuditedDbContext]]
end
subgraph Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.DbContext[[DbContext]]
end
Microsoft.EntityFrameworkCore.DbContext --> EasyExtensions.EntityFrameworkCore.Database.AuditedDbContext
| Returns | Name |
|---|---|
int |
SaveChanges()Saves all changes made in this context to the database and update Modified and Created datetime. |
Task<int> |
SaveChangesAsync(...)Saves all changes made in this context to the database and update Modified and Created datetime. |
A DbContext instance represents a session with the database and can be used to query and save instances of your entities. DbContext is a combination of the Unit Of Work and Repository patterns. This version of DbContext is designed for automated auditing of entities.
DbContext
protected AuditedDbContext()Initializes a new instance of the DbContext class. The DbContext.OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder) method will be called to configure the database (and other options) to be used for this context.
See DbContext lifetime, configuration, and initialization for more information and examples.
public AuditedDbContext(DbContextOptions options)| Type | Name | Description |
|---|---|---|
DbContextOptions |
options | The options for this context. |
Initializes a new instance of the DbContext class using the specified options. The DbContext.OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder) method will still be called to allow further configuration of the options.
See DbContext lifetime, configuration, and initialization and Using DbContextOptions for more information and examples.
public override int SaveChanges()Saves all changes made in this context to the database and update Modified and Created datetime.
The number of state entries written to the database.
| Name | Description |
|---|---|
| DbUpdateException | An error is encountered while saving to the database. |
| DbUpdateConcurrencyException | A concurrency violation is encountered while saving to the database. A concurrency violation occurs when an unexpected number of rows are affected during save. This is usually because the data in the database has been modified since it was loaded into memory. |
public override Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken)| Type | Name | Description |
|---|---|---|
bool |
acceptAllChangesOnSuccess | Indicates whether ChangeTracker.AcceptAllChanges is called after the changes have been sent successfully to the database. |
CancellationToken |
cancellationToken | A CancellationToken to observe while waiting for the task to complete. |
Saves all changes made in this context to the database and update Modified and Created datetime.
A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database.
| Name | Description |
|---|---|
| DbUpdateException | An error is encountered while saving to the database. |
| DbUpdateConcurrencyException | A concurrency violation is encountered while saving to the database. A concurrency violation occurs when an unexpected number of rows are affected during save. This is usually because the data in the database has been modified since it was loaded into memory. |
| OperationCanceledException | If the CancellationToken is canceled. |
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken)| Type | Name | Description |
|---|---|---|
CancellationToken |
cancellationToken | A CancellationToken to observe while waiting for the task to complete. |
Saves all changes made in this context to the database.
A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database.
| Name | Description |
|---|---|
| DbUpdateException | An error is encountered while saving to the database. |
| DbUpdateConcurrencyException | A concurrency violation is encountered while saving to the database. A concurrency violation occurs when an unexpected number of rows are affected during save. This is usually because the data in the database has been modified since it was loaded into memory. |
| OperationCanceledException | If the CancellationToken is canceled. |
Generated with ModularDoc