Class SqlEntityFrameworkRepositoryBase<TEntity, TDbContext>
Base class implementation of the repository pattern for an EF Core entity data type stored in SQL Server. This provides standardized access to the DbContext and implements IDispoable.
Inheritance
SqlEntityFrameworkRepositoryBase<TEntity, TDbContext>
Implements
Inherited Members
Namespace: Benday.EfCore.SqlServer
Assembly: Benday.EfCore.SqlServer.dll
Syntax
public abstract class SqlEntityFrameworkRepositoryBase<TEntity, TDbContext> : IDisposable where TEntity : class, IEntityBase where TDbContext : DbContext
Type Parameters
Name | Description |
---|---|
TEntity | Entity data type managed by this repository implementation. Must be an instance of IInt32Identity. |
TDbContext | EF Core DbContext data type that manages this entity |
Constructors
| Edit this page View SourceSqlEntityFrameworkRepositoryBase(TDbContext)
Declaration
protected SqlEntityFrameworkRepositoryBase(TDbContext context)
Parameters
Type | Name | Description |
---|---|---|
TDbContext | context |
Properties
| Edit this page View SourceContext
The instance of EF Core DbContext used by the repository.
Declaration
protected TDbContext Context { get; }
Property Value
Type | Description |
---|---|
TDbContext |
Methods
| Edit this page View SourceDispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Dispose(bool)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
VerifyItemIsAddedOrAttachedToDbSet(DbSet<TEntity>, TEntity)
Verifies that an object is attached to the DbContext instance and attaches it if necessary.
Declaration
protected void VerifyItemIsAddedOrAttachedToDbSet(DbSet<TEntity> dbset, TEntity item)
Parameters
Type | Name | Description |
---|---|---|
DbSet<TEntity> | dbset | DbSet instance that should contain this entity |
TEntity | item | Entity instance to verify is attached |