내 메서드에서 expression 매개 변수를 확장하여 자체 필터를 추가하고 싶습니다. 나는 다음과 같은 일을하려고하지만 구문이 잘못되었습니다 :λ 식 매개 변수에서 조건자를 확장하는 방법
public static IList<MyPage> DoSomething<T>(Expression<Func<T, bool>> predicate)
{
return DataStore().GetPages().Where(p => p.PublishDate < DateTime.Now && predicate)
}
컴파일러는이 오류와 함께 비주얼 스튜디오 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
예 IQueryable을 반환합니다 – TruMan1
죄송합니다 실제로 IList를 반환했습니다 – TruMan1