コード例 #1
0
ファイル: QueryableExtensions.cs プロジェクト: Hduc/Project
 public static IQueryable <T> Including <T>(this IQueryable <T> queryable, IncludingQuery <T> includingQuery)
     where T : class
 {
     return(includingQuery == null
         ? queryable
         : includingQuery.Columns.Aggregate(queryable, (x, y) => x.IncludeOptimized(y)));
 }
コード例 #2
0
ファイル: Repository.cs プロジェクト: Hduc/Project
 public async Task <TEntity> FindAsync(
     Expression <Func <TEntity, bool> > predicate,
     IncludingQuery <TEntity> includingQuery = null,
     CancellationToken cancellationToken     = default)
 {
     return(await Queryable(predicate, includingQuery).SingleOrDefaultAsync(cancellationToken));
 }
コード例 #3
0
ファイル: Repository.cs プロジェクト: Hduc/Project
 private IQueryable <TEntity> Queryable(
     Expression <Func <TEntity, bool> > predicate,
     IncludingQuery <TEntity> includingQuery = null,
     OrderingQuery <TEntity> orderingQuery   = null,
     PagingQuery pagingQuery = null)
 {
     return(DbSet.Where(predicate).Including(includingQuery).Ordering(orderingQuery).Paging(pagingQuery));
 }
コード例 #4
0
ファイル: Repository.cs プロジェクト: Hduc/Project
 public async Task <IReadOnlyList <TEntity> > GetAsync(
     Expression <Func <TEntity, bool> > predicate,
     IncludingQuery <TEntity> includingQuery = null,
     OrderingQuery <TEntity> orderingQuery   = null,
     PagingQuery pagingQuery             = null,
     CancellationToken cancellationToken = default)
 {
     return(await Queryable(predicate, includingQuery, orderingQuery, pagingQuery)
            .ToListAsync(cancellationToken));
 }