protected virtual async Task AsQueryableTest( Func <IIncludableQueryable <Product, ICollection <Part> >, Task <List <Product> > > toList) { // Create new empty database using (var db = new SQLiteContext()) { // Arrange IEntityFrameworkRepository <Category> cr = new EntityFrameworkRepository <Category>(db); var category = CreateCategory(100); cr.Create(category); IEntityFrameworkRepository <Product> pr = new EntityFrameworkRepository <Product>(db); var q = pr .AsQueryable() .Where(p => p.Id > 1) .Skip(2) .Take(40) .OrderBy(p => p.Name) .Include(p => p.Parts); // Act var pageItems = await toList(q); // Assert Assert.NotNull(pageItems); Assert.Equal(40, pageItems.Count()); } }
public async Task <long?> CountAsync <T>() where T : class { var repo = new EntityFrameworkRepository <T>(dbContext); return(await repo.AsQueryable() .LongCountAsync()); }
public IEnumerable <T> ApplyQueryOptions <T>(ODataQueryOptions queryOptions) where T : class { var repo = new EntityFrameworkRepository <T>(dbContext); return(repo.AsQueryable() .OData() .ApplyQueryOptionsWithoutSelectExpand(queryOptions)); }