Interface IDbContext
- Assembly
- Stratara.EventSourcing.EntityFrameworkCore.dll
Minimal DbContext surface that Stratara repositories program against, exposing the parts of DbContext needed for persistence without depending on the concrete EF Core type.
public interface IDbContext
- Extension Methods
Remarks
Implemented by the Write, Read, and Identity DbContexts so that repositories and unit-of-work implementations can be constructor-injected without a hard coupling to a specific context type.
Properties
ChangeTracker
Gets the EF Core change tracker for the current context.
ChangeTracker ChangeTracker { get; }
Property Value
Database
Gets the database facade for migrations, transactions, and raw SQL.
DatabaseFacade Database { get; }
Property Value
Methods
SaveChanges()
Persists all pending changes to the underlying database synchronously.
int SaveChanges()
Returns
- int
The number of state entries written to the database.
SaveChangesAsync(CancellationToken)
Persists all pending changes to the underlying database asynchronously.
Task<int> SaveChangesAsync(CancellationToken token = default)
Parameters
tokenCancellationTokenToken used to cancel the save operation.
Returns
Set<TEntity>()
Returns a DbSet<TEntity> for the given entity type.
DbSet<TEntity> Set<TEntity>() where TEntity : class
Returns
- DbSet<TEntity>
Type Parameters
TEntityThe entity type tracked by the context.