protected override async Task <IQueryable <BasketItem> > CreateFilteredQueryAsync(GetBasketItemListDto input) { var userId = input.UserId ?? CurrentUser.GetId(); return((await ReadOnlyRepository.GetQueryableAsync()) .Where(item => item.UserId == userId && item.BasketName == input.BasketName)); }
protected override async Task <System.Linq.IQueryable <Blog> > CreateFilteredQueryAsync(BlogListInput input) { if (input.IncludeDetails) { if (input.UseIncludeFilter) { // https://docs.microsoft.com/en-us/ef/core/querying/related-data/eager#filtered-include return((await ReadOnlyRepository.GetQueryableAsync()) .Include(x => x.Posts // Note: Ensures the collection is not loaded in to memory prior to evaluation (not really required here though) .AsQueryable() .Where(x => x.ConcurrencyStamp != null && x.ExtraProperties != null) ) // see: https://docs.microsoft.com/en-us/ef/core/querying/single-split-queries#split-queries-1 // Note: Default behaviour for collections. Creates a filtered SQL query for root 'Blog' entity, then another Query for filtered Blog.Posts when they are projected/accessed. //.AsSplitQuery() // Note: Default behaviour for on-to-one entities. Forces all data to be fetched in one query (and generates a 'LEFT JOIN' on Posts table). Can cause cartesian explosion when working with collections. //.AsSingleQuery() ); } return(await ReadOnlyRepository.WithDetailsAsync(b => b.Posts)); } return(await ReadOnlyRepository.GetQueryableAsync()); }
protected override async Task <System.Linq.IQueryable <Post> > CreateFilteredQueryAsync(PostListInput input) { //return (await (input.IncludeDetails // ? ReadOnlyRepository.WithDetailsAsync(p => p.Blog) // : ReadOnlyRepository.GetQueryableAsync())); if (input.UseQuerySyntax) { return(await PostRepository.GetUsingQuerySyntaxAsync(input.IncludeDetails)); } else { if (input.IncludeDetails) { return((await ReadOnlyRepository.GetQueryableAsync()) //.IgnoreQueryFilters() // Bypass all ABP filters for a query (ignores filters like ISoftDelete/IMultiTenant) // note: the additional 'Where' calls are to test that the 'IgnoreAbpQueryFilters' call is stripped without stripping any other calls //.Where(p => p.LastModificationTime == null).IgnoreAbpQueryFilters().Where(p => p.LastModificationTime == null) // These could be difficult to evaluate //.Include(p => p.Blog).ThenInclude(b => b.Posts) //.Include(p => p.Blog.Posts) .Include(p => p.Blog) // Thankfully this fails - so we don't need to account for includes with method calls //.Include(p => p.Blog.Posts.First().Blog) ); } else { // This should not filter entities because nothing was included ('Include()' was not called) return(await ReadOnlyRepository.GetQueryableAsync()); } } }
protected virtual async Task <IQueryable <TEntity> > CreateFilteredQueryAsync <TWhere>(TWhere inputDto, string methodStringType) { return(CreateFilteredQuery(await ReadOnlyRepository.GetQueryableAsync(), inputDto, methodStringType)); }
protected override async Task <IQueryable <Book> > CreateFilteredQueryAsync(GetBookListInput input) { return((await ReadOnlyRepository.GetQueryableAsync()).WhereIf(input.UserId.HasValue, x => x.UserId == input.UserId.Value)); }