Skip to content

EF Common

Ivan Kozhin edited this page Sep 8, 2020 · 5 revisions

Pagination

1. EFTotalCountListFactory.FromSourceAsync

Task<TotalCountList<T>> FromSourceAsync<T>(
  IQueryable<T> source,
  CancellationToken cancellationToken = default)

Creates a list with the total count from the queryable source. The calling will evaluate the query automatically.

2. EFOffsetLimitListFactory.FromSourceAsync

Task<OffsetLimitList<T>> FromSourceAsync<T>(I
  Queryable<T> source,
  int offset,
  int limit,
  CancellationToken cancellationToken = default)

Creates a new list with limit and offset properties from the queryable source. The calling will evaluate the query automatically.

3. EFPagedListFactory.FromSourceAsync

Task<PagedList<T>> FromSourceAsync<T>(
  IQueryable<T> source,
  int page,
  int pageSize,
  CancellationToken cancellationToken = default)

Creates a paged list from queryable source and query source by page and page size. The calling will evaluate the query automatically.

4. EFPagedListFactory.AsOnePage

Task<PagedList<T>> AsOnePage<T>(
  IQueryable<T> source,
  CancellationToken cancellationToken = default)

Returns collection of items as a paged list as one page.

DbSet Extensions

1. GetAsync

Task<TEntity> GetAsync<TEntity>(this DbSet<TEntity> entities, params object[] keyValues);
Task<TEntity> GetAsync<TEntity>(this DbSet<TEntity> entities, CancellationToken cancellationToken,
  params object[] keyValues);

Get the entity by key values. Throws NotFoundException if the entity not found.

Clone this wiki locally