'How to transform OData filter to a LINQ expression?

I'm trying to extract the filter expression from ODataQueryOptions so that I can use it in my business logic class.

public PageResult<Poco> Get(ODataQueryOptions odataQueryOptions)
{
    Expression<Func<Poco, bool>> myExpression = ... // what do i do here?

    var result = _myBusinessLogic.Search(myExpression);
    return new PageResult<Poco>(result, null, null);
}

I took a look at the blog describing translating the query into HQL here and I think (at least I hope) that's an overkill for what I'm trying to do.

I basically need to get the filter expression in the Expression<Func<Poco, bool>> form. I tried playing with ApplyTo() but I can't quite get it. Any help appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source