How do I create a generic Expression that has an expression as a parameter

前端 未结 4 1908
死守一世寂寞
死守一世寂寞 2021-01-06 18:32

There is a DisplayNameFor(x=>x.Title) helper in ASP.Net MVC. I want to implement something similar in behavior.

I want to have a method that accepts

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-06 18:53

    I believe this is what you're aiming for.

    public Func MyMethod(Expression> func, ComparisonPredicate op, TProperty value)
    {
    
    
    }
    
    public enum ComparisonPredicate
    {
        Equal,
        Unequal,
        LessThan,
        LessThanOrEqualTo,
        GreaterThan,
        GreaterThanOrEqualTo
    }
    

提交回复
热议问题