Class EfCoreDataStore<T>
- Namespace
- Savvyio.Extensions.EFCore
- Assembly
- Savvyio.Extensions.EFCore.dll
Provides a default implementation of the IPersistentDataStore<T, TOptions> interface to serve as an abstraction layer before the actual I/O communication with a source of data using Microsoft Entity Framework Core.
public class EfCoreDataStore<T> : IPersistentDataStore<T, EfCoreQueryOptions<T>>, IWritableDataStore<T>, IReadableDataStore<T>, ISearchableDataStore<T, EfCoreQueryOptions<T>>, IDeletableDataStore<T>, IDataStore<T> where T : class
Type Parameters
TThe type of the DTO.
- Inheritance
-
EfCoreDataStore<T>
- Implements
-
IDataStore<T>
- Derived
Constructors
EfCoreDataStore(IEfCoreDataSource)
Initializes a new instance of the EfCoreDataStore<T> class.
public EfCoreDataStore(IEfCoreDataSource source)
Parameters
sourceIEfCoreDataSourceThe IEfCoreDataSource that handles actual I/O communication with a source of data.
Properties
Set
Gets a DbSet<TEntity> that can be used to query and save instances of T.
protected DbSet<T> Set { get; }
Property Value
- DbSet<T>
The DbSet<TEntity> that can be used to query and save instances of
T.
UnitOfWork
Gets a IUnitOfWork that can be used to save instances of T.
protected IUnitOfWork UnitOfWork { get; }
Property Value
- IUnitOfWork
The IUnitOfWork that can be used to save instances of
T.
Methods
CreateAsync(T, Action<AsyncOptions>)
Creates the specified dto asynchronous in the associated IEfCoreDataSource.
public virtual Task CreateAsync(T dto, Action<AsyncOptions> setup = null)
Parameters
dtoTThe object to create in the associated IEfCoreDataSource.
setupAction<AsyncOptions>The AsyncOptions which may be configured.
Returns
DeleteAsync(T, Action<AsyncOptions>)
Deletes the specified dto asynchronous in the associated IEfCoreDataSource.
public virtual Task DeleteAsync(T dto, Action<AsyncOptions> setup = null)
Parameters
dtoTThe object to delete in the associated IEfCoreDataSource.
setupAction<AsyncOptions>The AsyncOptions which may be configured.
Returns
FindAllAsync(Action<EfCoreQueryOptions<T>>)
Finds all objects matching the specified setup asynchronous in the associated IEfCoreDataSource.
public virtual Task<IEnumerable<T>> FindAllAsync(Action<EfCoreQueryOptions<T>> setup = null)
Parameters
setupAction<EfCoreQueryOptions<T>>The EfCoreQueryOptions<T> which may be configured.
Returns
- Task<IEnumerable<T>>
A Task<TResult> that represents the asynchronous operation. The task result either contains the matching objects of the operation or an empty sequence if no match was found.
GetByIdAsync(object, Action<AsyncOptions>)
Loads the object from the specified id asynchronous.
public virtual Task<T> GetByIdAsync(object id, Action<AsyncOptions> setup = null)
Parameters
idobjectThe key that uniquely identifies the object.
setupAction<AsyncOptions>The AsyncOptions which may be configured.
Returns
- Task<T>
A Task<TResult> that represents the asynchronous operation. The task result either contains the object of the operation or
nullif not found.
UpdateAsync(T, Action<AsyncOptions>)
Updates the specified dto asynchronous in the associated IEfCoreDataSource.
public virtual Task UpdateAsync(T dto, Action<AsyncOptions> setup = null)
Parameters
dtoTThe object to update in the associated IEfCoreDataSource.
setupAction<AsyncOptions>The AsyncOptions which may be configured.