Skip to content

How do we hookup a custom IQueryable logic to the filter/sort configurations? #3176

Answered by gojanpaolo
gojanpaolo asked this question in Q&A
Discussion options

You must be logged in to vote

I think I got it.. Basically, there is a QueryableDefaultFieldHandler that we can inherit and override TryHandleEnter instead of implementing IFilterFieldHandler..

Everything stays the same with the sample on first post above except for the StatusHandler implementation which is now:

public class StatusHandler : QueryableDefaultFieldHandler
{
    public override bool TryHandleEnter(QueryableFilterContext context, IFilterField field, ObjectFieldNode node, [NotNullWhen(true)] out ISyntaxVisitorAction? action)
    {
        Expression<Func<Employee, bool>> expression =
            (string)node.Value.Value! == "IN"
            ? _ => _.Times.OrderByDescending(_ => _.Out ?? _.In).First().Out ==…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@gojanpaolo
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by gojanpaolo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants