Class EfCoreDbSet<TEntity>
An implementation of IDbSet<TEntity> that works with Entity Framework Core.
Implements
Inherited Members
Namespace: Silverback.Database
Assembly: Silverback.Core.EFCore30.dll
Syntax
public class EfCoreDbSet<TEntity> : IDbSet<TEntity> where TEntity : class
Type Parameters
| Name | Description |
|---|---|
| TEntity | The type of the entity being stored in this set. |
Constructors
| Improve this doc View sourceEfCoreDbSet(DbSet<TEntity>)
Initializes a new instance of the EfCoreDbSet<TEntity> class.
Declaration
public EfCoreDbSet(DbSet<TEntity> dbSet)
Parameters
| Type | Name | Description |
|---|---|---|
| DbSet<TEntity> | dbSet | The underlying DbSet<TEntity>. |
Methods
| Improve this doc View sourceAdd(TEntity)
Adds the specified entity to the set and start tracking it. The entity will be inserted into the database when saving changes.
Declaration
public TEntity Add(TEntity entity)
Parameters
| Type | Name | Description |
|---|---|---|
| TEntity | entity | The entity to be added. |
Returns
| Type | Description |
|---|---|
| TEntity | The added entity. |
AsQueryable()
Returns an IQueryable to query the set.
Declaration
public IQueryable<TEntity> AsQueryable()
Returns
| Type | Description |
|---|---|
| IQueryable<TEntity> | An IQueryable<T>. |
Find(params object[])
Finds the entity with the specified key(s). Returns null if not found.
Declaration
public TEntity? Find(params object[] keyValues)
Parameters
| Type | Name | Description |
|---|---|---|
| object[] | keyValues | The entity keys. |
Returns
| Type | Description |
|---|---|
| TEntity | The entity found, or |
FindAsync(params object[])
Finds the entity with the specified key(s). Returns null if not found.
Declaration
public Task<TEntity?> FindAsync(params object[] keyValues)
Parameters
| Type | Name | Description |
|---|---|---|
| object[] | keyValues | The entity keys. |
Returns
| Type | Description |
|---|---|
| Task<TEntity> | The entity found, or |
GetLocalCache()
Returns the locally cached entities.
Declaration
public IEnumerable<TEntity> GetLocalCache()
Returns
| Type | Description |
|---|---|
| IEnumerable<TEntity> | The entities in the local cache. |
Remove(TEntity)
Removes the specified entity from the set causing it to be deleted when saving changes.
Declaration
public TEntity Remove(TEntity entity)
Parameters
| Type | Name | Description |
|---|---|---|
| TEntity | entity | The entity to be removed. |
Returns
| Type | Description |
|---|---|
| TEntity | The removed entity. |
RemoveRange(IEnumerable<TEntity>)
Removes the specified entities from the set causing them to be deleted when saving changes.
Declaration
public void RemoveRange(IEnumerable<TEntity> entities)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TEntity> | entities | The entities to be removed. |