我想扩展我的方法中的表达式参数以添加我自己的过滤器。我试图做类似以下,但语法是错误的:如何在lambda表达式参数中扩展谓词
public static IList<MyPage> DoSomething<T>(Expression<Func<T, bool>> predicate)
{
return DataStore().GetPages().Where(p => p.PublishDate < DateTime.Now && predicate)
}
编译器抱怨在Visual Studio 2012是抱怨与此错误:
Error 29 Operator '&&' cannot be applied to operands of type '
bool
' and 'System.Linq.Expressions.Expression<System.Func<T,bool>>
'
将延长谓语第一个会更好那么回馈如果回.Where(predicate)
?你会怎么做?
我想'GETPAGES()'返回'IQueryale',对吧? –
svick
2013-02-23 09:50:39
是的,它确实返回IQueryable – TruMan1 2013-02-23 09:52:57
对不起实际返回IList – TruMan1 2013-02-23 10:16:16