Base solution for your next web application
Open Closed

"WhereIf" method of using? #245


User avatar
0
ghua created

Hi~

Can you tell me the filter criteria "WhereIf" how to use it? Can you give me an example?


2 Answer(s)
  • User Avatar
    0
    daws created

    searching on gitHub <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/search?utf8=%E2%9C%93&q=WhereIf">https://github.com/aspnetboilerplate/as ... &q=WhereIf</a>

    the third example could maybe help you.

  • User Avatar
    0
    hikalkan created
    Support Team

    Thanks @daws. An example usage for IQueryable<T>:

    var ternants = _tenantRepository.GetAll()
                    .WhereIf(input.GetOnlyActives, t => t.IsActive)
                    .WhereIf(
                        !input.Filter.IsNullOrWhiteSpace(),
                        t =>
                            t.Name.Contains(input.Filter) ||
                            t.TenancyName.Contains(input.Filter)
                    )
                    .ToList();
    

    It also works for IEnumerable<T>.