Show / Hide Table of Contents

Class SqlEntityFrameworkSearchableRepositoryBase<TEntity, TDbContext>

Base class implementation of the repository pattern for an EF Core entity data type stored in SQL Server that supports searching using Benday.Common.Search functionality.

Inheritance
object
SqlEntityFrameworkRepositoryBase<TEntity, TDbContext>
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>
SqlEntityFrameworkSearchableRepositoryBase<TEntity, TDbContext>
Implements
IDisposable
ISearchableRepository<TEntity>
IRepository<TEntity>
Inherited Members
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.EntityDbSet
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.Delete(TEntity)
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.BeforeDelete(TEntity)
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.AfterDelete(TEntity)
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.Includes
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.GetAll()
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.BeforeGetAll(IQueryable<TEntity>)
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.AddDefaultSort(IQueryable<TEntity>)
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.GetAll(int, bool)
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.AddIncludes(IQueryable<TEntity>)
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.GetById(int)
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.Save(TEntity)
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.BeforeSaveOnDependentEntities(TEntity)
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.BeforeSave(TEntity)
SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>.AfterSave(TEntity)
SqlEntityFrameworkRepositoryBase<TEntity, TDbContext>.Dispose()
SqlEntityFrameworkRepositoryBase<TEntity, TDbContext>.Dispose(bool)
SqlEntityFrameworkRepositoryBase<TEntity, TDbContext>.Context
SqlEntityFrameworkRepositoryBase<TEntity, TDbContext>.VerifyItemIsAddedOrAttachedToDbSet(DbSet<TEntity>, TEntity)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Benday.EfCore.SqlServer
Assembly: Benday.EfCore.SqlServer.dll
Syntax
public abstract class SqlEntityFrameworkSearchableRepositoryBase<TEntity, TDbContext> : SqlEntityFrameworkCrudRepositoryBase<TEntity, TDbContext>, IDisposable, ISearchableRepository<TEntity>, IRepository<TEntity> 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 Source

SqlEntityFrameworkSearchableRepositoryBase(TDbContext)

Constructor

Declaration
public SqlEntityFrameworkSearchableRepositoryBase(TDbContext context)
Parameters
Type Name Description
TDbContext context

EF Core DbContext to wrap

Methods

| Edit this page View Source

AddSort(IOrderedQueryable<TEntity>, SortBy, bool)

Adds a sort directive to the query

Declaration
protected virtual IOrderedQueryable<TEntity> AddSort(IOrderedQueryable<TEntity> query, SortBy sort, bool isFirstSort)
Parameters
Type Name Description
IOrderedQueryable<TEntity> query

Query instance

SortBy sort

Sort information

bool isFirstSort

Is this the first sort call to be added?

Returns
Type Description
IOrderedQueryable<TEntity>
| Edit this page View Source

AddSortAscending(IOrderedQueryable<TEntity>, string, bool)

Abstract method for adding a ascending sort to a repository search query

Declaration
protected abstract IOrderedQueryable<TEntity> AddSortAscending(IOrderedQueryable<TEntity> query, string propertyName, bool isFirstSort)
Parameters
Type Name Description
IOrderedQueryable<TEntity> query

The query instance

string propertyName

Property name to add

bool isFirstSort

Is this the first sort call to be added?

Returns
Type Description
IOrderedQueryable<TEntity>

The updated query

| Edit this page View Source

AddSortDescending(IOrderedQueryable<TEntity>, string, bool)

Abstract method for adding a descending sort to a repository search query

Declaration
protected abstract IOrderedQueryable<TEntity> AddSortDescending(IOrderedQueryable<TEntity> query, string propertyName, bool isFirstSort)
Parameters
Type Name Description
IOrderedQueryable<TEntity> query

The query instance

string propertyName

Property name to add

bool isFirstSort

Is this the first sort call to be added?

Returns
Type Description
IOrderedQueryable<TEntity>

The updated query

| Edit this page View Source

AddSorts(Search, IQueryable<TEntity>)

Add multiple sorts to a repository search query

Declaration
protected virtual IQueryable<TEntity> AddSorts(Search search, IQueryable<TEntity> query)
Parameters
Type Name Description
Search search

The search request

IQueryable<TEntity> query

The query instance to update

Returns
Type Description
IQueryable<TEntity>

The updated query

Exceptions
Type Condition
ArgumentNullException
| Edit this page View Source

BeforeSearch(IQueryable<TEntity>, Search)

Template method that allows custom logic before a search is executed

Declaration
protected virtual IQueryable<TEntity> BeforeSearch(IQueryable<TEntity> query, Search search)
Parameters
Type Name Description
IQueryable<TEntity> query
Search search
Returns
Type Description
IQueryable<TEntity>
| Edit this page View Source

EnsureIsOrderedQueryable(IQueryable<TEntity>)

Takes the available query instance and makes sure that it's IOrderedQueryable

Declaration
protected virtual IOrderedQueryable<TEntity> EnsureIsOrderedQueryable(IQueryable<TEntity> query)
Parameters
Type Name Description
IQueryable<TEntity> query

The original query

Returns
Type Description
IOrderedQueryable<TEntity>

The original instance or a new wrapped instance of that query as IOrderedQueryable

| Edit this page View Source

GetPredicateForContains(SearchArgument)

Abstract method to get an EF Core query predicate for processing a 'contains' operation

Declaration
protected abstract Expression<Func<TEntity, bool>> GetPredicateForContains(SearchArgument arg)
Parameters
Type Name Description
SearchArgument arg

Search argument definition

Returns
Type Description
Expression<Func<TEntity, bool>>

The EF Core query predicate

| Edit this page View Source

GetPredicateForDoesNotContain(SearchArgument)

Abstract method to get an EF Core query predicate for processing a 'does not contain' operation

Declaration
protected abstract Expression<Func<TEntity, bool>> GetPredicateForDoesNotContain(SearchArgument arg)
Parameters
Type Name Description
SearchArgument arg

Search argument definition

Returns
Type Description
Expression<Func<TEntity, bool>>

The EF Core query predicate

| Edit this page View Source

GetPredicateForEndsWith(SearchArgument)

Abstract method to get an EF Core query predicate for processing a 'ends with' operation

Declaration
protected abstract Expression<Func<TEntity, bool>> GetPredicateForEndsWith(SearchArgument arg)
Parameters
Type Name Description
SearchArgument arg

Search argument definition

Returns
Type Description
Expression<Func<TEntity, bool>>

The EF Core query predicate

| Edit this page View Source

GetPredicateForEquals(SearchArgument)

Abstract method to get an EF Core query predicate for processing an 'equals' operation

Declaration
protected abstract Expression<Func<TEntity, bool>> GetPredicateForEquals(SearchArgument arg)
Parameters
Type Name Description
SearchArgument arg

Search argument definition

Returns
Type Description
Expression<Func<TEntity, bool>>

The EF Core query predicate

| Edit this page View Source

GetPredicateForIsNotEqualTo(SearchArgument)

Abstract method to get an EF Core query predicate for processing a 'not equal' operation

Declaration
protected abstract Expression<Func<TEntity, bool>> GetPredicateForIsNotEqualTo(SearchArgument arg)
Parameters
Type Name Description
SearchArgument arg

Search argument definition

Returns
Type Description
Expression<Func<TEntity, bool>>

The EF Core query predicate

| Edit this page View Source

GetPredicateForStartsWith(SearchArgument)

Abstract method to get an EF Core query predicate for processing a 'starts with' operation

Declaration
protected abstract Expression<Func<TEntity, bool>> GetPredicateForStartsWith(SearchArgument arg)
Parameters
Type Name Description
SearchArgument arg

Search argument definition

Returns
Type Description
Expression<Func<TEntity, bool>>

The EF Core query predicate

| Edit this page View Source

Search(Search)

Execute a search for this entity type and return the matching result.

Declaration
public virtual SearchResult<TEntity> Search(Search search)
Parameters
Type Name Description
Search search

Search definition with arguments, search operation methods, and sorting information

Returns
Type Description
SearchResult<TEntity>

The result of the search

Implements

IDisposable
ISearchableRepository<T>
IRepository<T>
  • Edit this page
  • View Source
In this article
  • Constructors
    • SqlEntityFrameworkSearchableRepositoryBase(TDbContext)
  • Methods
    • AddSort(IOrderedQueryable<TEntity>, SortBy, bool)
    • AddSortAscending(IOrderedQueryable<TEntity>, string, bool)
    • AddSortDescending(IOrderedQueryable<TEntity>, string, bool)
    • AddSorts(Search, IQueryable<TEntity>)
    • BeforeSearch(IQueryable<TEntity>, Search)
    • EnsureIsOrderedQueryable(IQueryable<TEntity>)
    • GetPredicateForContains(SearchArgument)
    • GetPredicateForDoesNotContain(SearchArgument)
    • GetPredicateForEndsWith(SearchArgument)
    • GetPredicateForEquals(SearchArgument)
    • GetPredicateForIsNotEqualTo(SearchArgument)
    • GetPredicateForStartsWith(SearchArgument)
    • Search(Search)
  • Implements
Back to top Copyright © www.benday.com | info@benday.com