0

I am trying to search the product name using the given keyword but my boilerplate throw me error

I tried

protected override IQueryable<Product> CreateFilteredQuery(PagedProductResultRequestDto input)
{
    return base.CreateFilteredQuery(input).
        WhereIf(input.Keyword.IsNullOrWhiteSpace(), x => x.Name.Contains(input.Keyword));
}

gave me error

Cannot implicitly convert type ‘System.Linq.IQueryable’ to ‘System.Collections.Generic.IEnumerable’. An explicit conversion exists (are you missing a cast?)

4

2 回答 2

3

修正你的using指令。

// using Abp.Collections.Extensions; // EnumerableExtensions.WhereIf returns IEnumerable<T>
   using Abp.Linq.Extensions;        // QueryableExtensions.WhereIf returns IQueryable<T>
于 2019-08-14T17:21:46.550 回答
0
protected IQueryable<Product> CreateFilteredCategory(Collection<Product> input)
    {
        return input.Where(x => x.ProductName.Contains("Test")).AsQueryable<Product>();
    }

这些类并不完全相同,但前提是。

于 2019-08-14T12:47:48.897 回答