Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

.WhereIf is converting an IQueryable<T> to IEnumerable<T> #2624


User avatar
0
bilalhaidar created

Hi,

In an AppService, I have this code:

var query = _manager.Shelters
               .WhereIf(
                   !input.Filter.IsNullOrWhiteSpace(),
                   t =>
                       t.ShelterCode.ToLower().Contains(input.Filter.Trim().ToLower()) ||
                       t.ShelterSubCode.ToLower().Contains(input.Filter.Trim().ToLower())
               );

The _manager.Shelters is defined in the manager as:

public virtual IQueryable<Shelter> Shelters { get { return _repository.GetAll(); } }

Now, if I hover over query above, it says it is of type IEnumerable<Shelter>. I want it to stay IQueryable<Shelter> so that I can do additional filtering, sorting, etc.

I tried to remove (WhereIf), then if I hover over query it displays IQueryable<Shelter>

The same code used in TenantAppService, works fine there. Am I missing any namespace reference?

Thanks


3 Answer(s)
  • User Avatar
    0
    bilalhaidar created

    I was missing this reference:

    using Abp.Linq.Extensions;

    Regards Bilal

  • User Avatar
    0
    ismcagdas created
    Support Team

    You started to answer your own questions :)

  • User Avatar
    0
    bilalhaidar created

    Yes :)

    I thought of not deleting the post in case someone else faced the issue.

    Regards Bilal