0
    
    
        
                    TMuska created
                    
                    
                    
                
                - ABP Framework version: v7.4.4
- UI Type: Angular
- Database System: EF Core
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
Can you give me an example to override the CreateFilterExpression method using a string value for the query filter? Your example is using a bool. I want to have a global query filter that will filter by customer number, just like a tenant id. I followed your example but not able to get it to work with a string.
https://docs.abp.io/en/abp/latest/Data-Filtering
3 Answer(s)
- 
    0Could you show your code please? 
- 
    0I'm just trying to follow the example. Instead of IsActive/boolean, I'm trying to do CustomerNumber/string. protected override Expression<Func<TEntity, bool>> CreateFilterExpression<TEntity>() { var expression = base.CreateFilterExpression<TEntity>(); if (typeof(IIsActive).IsAssignableFrom(typeof(TEntity))) { Expression<Func<TEntity, bool>> isActiveFilter = e => !IsActiveFilterEnabled || EF.Property<bool>(e, "IsActive"); expression = expression == null ? isActiveFilter : QueryFilterExpressionHelper.CombineExpressions(expression, isActiveFilter); } return expression; }
- 
    0hi The expression must be Expression<Func<TEntity, bool>>If you have a string column you can try toExpression<Func<TEntity, bool>> myStringFilter = e => !IsMyFilterEnabled || EF.Property<string>(e, "MyString") == CurrentString;
 
                                