我想建立一个表达式为接受类型的参数上的方法的where子句如何从另一种表达构建表达式<Func键<T, bool>(表达式<Func键<T, DateTime>>)
Expression<Func<T, bool>>
Expression<Func<T, DateTime>>
我想操纵我的DateTime属性来比较它的内部属性,比如将比较子句添加到日,月和年属性。
我的方法是这样的:
public static class MyUtils
{
public static Expression<Func<T, bool>> GetTime<T>(this Expression<Func<T, bool>> pExp, Expression<Func<T, DateTime>> MyProperty, int day, int month, int year)
{
}
}
我想用这样的:
Expression<Func<MyClass, bool>> vExpression = p => false;
vExpression = vExpression.GetTime<MyClass>(c => c.MyDate, 21, 12, 2012);
因此,在我有我之间有一些比较“的方法结束指明MyDate “财产和个人日期值。
可以这样做吗?
看起来好吧,是你的问题吗? – Polity
我想要使用日,月和年的属性 –