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

best way to implement custom data filter with abp? #1545


User avatar
0
apexdodge created

Hi there, so I've created my own custom data filter following these directions: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Data-Filters">http://www.aspnetboilerplate.com/Pages/ ... ta-Filters</a>

However, the whole point of me creating the filter was so that I can call something like _articleRepository.GetAllList() without hassle. But in order to actually use the filter, I have to specify:

using(CurrentUnitOfWork.SetFilterParameter("ProductFilter", "productId", productId))
    {
        var articles = _articleRepository.GetAllList();
    }

If I have to do that every time I call my articleRepository, I might as well just abandon the filter and continue doing _articleRepository.GetAll().Where(p => p.ProductId == productId)...

I would like to know two things:

  1. The built-in filters like IMustHaveTenant and ISoftDelete don't need to be set the filter parameter every time I make a call unless I want to specifically override something. How / where did you set that filter parameter so that it need not be specified every time I make a call?

  2. The parameter of productId is passed in manually but I would like to pull the value from the url automatically like /admin/product/5/articles (5 in this case) --- what's the best way to pull from that when setting filter parameter?

Thanks so much.


2 Answer(s)
  • User Avatar
    0
    apexdodge created

    i came up with a half-decent solution. if anyone wants sample code, let me know

  • User Avatar
    0
    tkueny created

    How did you end up implementing this? I am in a similar situation. I am trying to have a data filter on some of my entities, but am running into an issue where I want the filter auto applied based off the url, and not sure how to use the filters with the auto generated app service apis.

    Thanks