Parsing ODataQueryOptions to Expression>
I guess that you're assuming that the MethodCall expression should be a call to Queryable.Where(...) ?


You should check that explicitly via something like :

// yea, that's ugly. But that's for the demo. 
//   I'm pretty sure you'll find the proper way to get the method info with your favorite method
static readonly MethodInfo QueryableWhere = ((MethodCallExpression)(
   (Expression&lt;Func&lt;IQueryable&lt;string&gt;&gt;&gt;)
    (() =&gt; ((IQueryable&lt;string&gt;)null).Where(x =&gt; true)))
   .Body.Unquote())
   .Method.GetGenericMethodDefinition();


and in your code

 if(!mce.Method.IsGeneric || mce.Method.GetGenericMethodDefinition() != QueryableWhere)
     throw an exception;

Unary expressions are not necessarily quotes! (a negation is an unary, for instance). Thus, you want to check mce.Arguments[1].NodeType instead of checking its type.

Moreover, quote un-quoting is quite common, so it can be useful to replace.

var quote = mce.Arguments[1] as UnaryExpression;
if(quote != null)
{
    return quote.Operand as Expression&lt;Func&lt;TEntity, bool&gt;&gt;;
}


by

return mce.Arguments[1].Unquote();


with

public static Expression Unquote(this Expression quote)
{
    if(quote.NodeType == ExpressionType.Quote)
        return ((UnaryExpression)quote).Operand.Unquote();
    return quote;
}

Returning a lambda is OK in my opinion. No problem with that IF AND ONLY IF there is no chance that the enclosed predicate does not contains any reference to an outer parameter (or variable), which is the case here, so it's okay.