Class GenericReadOnlyRepository<TEntity>
Class that represents a read-only repository for an entity in the context.
Implements
Inherited Members
Namespace: Fibula.Data.Repositories
Assembly: Fibula.Data.dll
Syntax
public abstract class GenericReadOnlyRepository<TEntity> : IReadOnlyRepository<TEntity> where TEntity : BaseEntity
Type Parameters
Name | Description |
---|---|
TEntity | The type of entity. |
Constructors
| Improve this Doc View SourceGenericReadOnlyRepository(DbContext)
Initializes a new instance of the GenericReadOnlyRepository<TEntity> class.
Declaration
public GenericReadOnlyRepository(DbContext context)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.EntityFrameworkCore.DbContext | context | The context to use with this repository. |
Properties
| Improve this Doc View SourceContext
Gets the reference to the context.
Declaration
protected DbContext Context { get; }
Property Value
Type | Description |
---|---|
Microsoft.EntityFrameworkCore.DbContext |
Methods
| Improve this Doc View SourceFindMany(Expression<Func<TEntity, Boolean>>)
Finds all the entities in the set within the context that satisfy an expression.
Declaration
public IEnumerable<TEntity> FindMany(Expression<Func<TEntity, bool>> predicate)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TEntity, System.Boolean>> | predicate | The expression to satisfy. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TEntity> | The collection of entities retrieved. |
FindOne(Expression<Func<TEntity, Boolean>>)
Finds an entity in the set within the context that satisfies an expression. If more than one entity satisfies the expression, one is picked up in an unknown criteria.
Declaration
public TEntity FindOne(Expression<Func<TEntity, bool>> predicate)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TEntity, System.Boolean>> | predicate | The expression to satisfy. |
Returns
Type | Description |
---|---|
TEntity | The entity found. |
GetAll()
Gets all the entities from the set in the context.
Declaration
public IEnumerable<TEntity> GetAll()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TEntity> | The collection of entities retrieved. |
GetById(String)
Gets an entity that matches an id, from the context.
Declaration
public TEntity GetById(string id)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | The id to match. |
Returns
Type | Description |
---|---|
TEntity | The entity found, if any. |