Entity Framework Core Repositories
Last updated
Last updated
Base Repository
Filterable
Queryable
Native EF Core queryable extensions
Pageable
Multi-tenant
Uses Finbuckle Multi-Tenant
The Deveel Repository framework provides an implementation of the repository pattern that uses the , and allows to access a wide range of relational databases.
The EntityRepository<TEntity>
class is an implementation of the repository pattern that wraps around an instance of DbContext
and provides the basic operations to query and manipulate the data.
To start using instances of the EntityRepository<TEntity>
class, you need first to register a DbContext
instance in the dependency injection container, that will be used to access the database, using one of the extensions methods of the IServiceCollection
interface: you don't receive any special provisioning from the library, and you can use the standard methods provided by the Entity Framework Core itself.
The registration of the repository in the dependency injection container is the same provided by the kernel library, and is the following:
or using the shortcut method, that will register the default implementation of the repository:
Remember that you still need to register the DbContext
in the dependency injection container, and that the EntityRepository<TEntity>
class requires a constructor that accepts an instance of DbContext
as parameter.
The simplest use case for this is the following set of calls:
The library provides a shortcut method to register the DbContext in multi-tenant applications, using the ITenantInfo interface provided by the framework.
For example:
The EntityRepository<TEntity>
implements both the IQueryableRepository<TEntity>
and the IFilterableRepository<TEntity>
interfaces, and allows to query the data only through the ExpressionFilter<TEntity>
class or through lambda expressions of type Expression<Func<TEntity, bool>>
.
For example, to retrieve all the entities of type MyEntity
that have a property Name
equal to "John"
:
or event simpler, using the lambda expression:
Note: Please, refer to the official documentation by Microsoft for more information on how to configure the DbContext in your application, and the documentation of the framework for more information on how to configure the multi-tenant support and its support for .