我有這樣的方法結合Lambda表達式
public Expression<Func<Auction, bool>> GetUnsetDatesAuctionsExpression()
{
if (condition)
return GetAllUnsetDatesAuctionsExpression();
else
return (a =>
(membershipUser.ProviderUserKey != null) &&
(a.OwnerReference == (Guid)membershipUser.ProviderUserKey) &&
((a.Starts == null) || (a.Ends == null)));
}
}
調用該方法
private Expression<Func<Auction, bool>> GetAllUnsetDatesAuctionsExpression()
{
return (a => (a.Starts == null) || (a.Ends == null));
}
的問題是,在上述公開方法我有以下線
(a.Starts == null) || (a.Ends == null)
這與私有方法中表達式的主體相同。現在
,這樣做,當然,不工作,因爲你不能和一個布爾值和表達
return (a =>
(membershipUser.ProviderUserKey != null) &&
(a.OwnerReference == (Guid)membershipUser.ProviderUserKey) &&
(GetAllUnsetDatesAuctionsExpression));
所以,問題是,我怎麼呼叫相結合,與私有方法
(membershipUser.ProviderUserKey != null) &&
(a.OwnerReference == (Guid)membershipUser.ProviderUserKey)
您是否嘗試過(GetAllUnsetDatesAuctionsExpression)(一)? – 2012-02-09 11:50:31