Skip to content

When pass any not exist filter, the Sieve ignore all filters and sorts. #193

Open
@kostazol

Description

After some researching, I found the problem - missing try/catch block in the ApplyFiltering method. This block exist in the Apply method, because of it when we pass a filter that doesn't exist in a model and doesn't exist in custom filters, we got exception SieveMethodNotFoundException in the ApplyCustomMethod method.
Because of it when we pass any not exist filter, the Sieve will ignore all filters and sorts, because it will be finished applying in catch block.

   public IQueryable<TEntity> Apply<TEntity>(
      TSieveModel model,
      IQueryable<TEntity> source,
      object[] dataForCustomMethods = null,
      bool applyFiltering = true,
      bool applySorting = true,
      bool applyPagination = true)
    {
      IQueryable<TEntity> result = source;
      if ((object) model == null)
        return result;
      try
      {
        if (applyFiltering)
          result = this.ApplyFiltering<TEntity>(model, result, dataForCustomMethods);
        if (applySorting)
          result = this.ApplySorting<TEntity>(model, result, dataForCustomMethods);
        if (applyPagination)
          result = this.ApplyPagination<TEntity>(model, result);
        return result;
      }
      catch (Exception ex)
      {
        if (!this.Options.Value.ThrowExceptions)
          return result;
        if (!(ex is SieveException))
          throw new SieveException(ex.Message, ex);
        throw;
      }
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions