Replies: 1 comment 2 replies
-
I had a markup goal that covers this situation but it's not implemented yet: #18 [CompareTo("A")]
[And]
[CompareTo("B", "C", CombineWith = CombineType.Or)] Unfortunately it's an unimplemented feature. So you can create your own attribute for your custom requirements or just you can write linq for your custom requirement. You can follow this document to create custom attributes: https://enisn-projects.io/docs/en/AutoFilterer/latest/examples/Custom-Expression-for-Property In your case following implementation will work: public class MyCustomSearchAttribute : FilteringOptionsBaseAttribute
{
public override Expression BuildExpression(Expression expressionBody, PropertyInfo targetProperty, PropertyInfo filterProperty, object value)
{
// Also means: x => x.A == "someValue" && (x.B == "someValue" || x.C == "somveValue")
return Expression.And(
Expression.Equal(
Expression.Property(expressionBody, "A"),
Expression.Constant(value)
),
Expression.Or(
Expression.Equal(
Expression.Property(expressionBody, "B"),
Expression.Constant(value)
),
Expression.Equal(
Expression.Property(expressionBody, "C"),
Expression.Constant(value)
)
)
);
}
} Then you can use that attribute in your Filter Object public class MyFilter : FilterBase
{
[MyCustomSearch]
public int Filter { get; set; }
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
@enisn Heya! I was thinking about complex query. For example I want filter like a == 3 && (b ==4 || c == 2).
Is it possible to do such filter via query?
Beta Was this translation helpful? Give feedback.
All reactions