1
我需要使用QueryOver而不是LINQ的,但我在努力重建以下查詢:如何使用NHibernate QueryOver而不是Linq創建此查詢?
public IQueryable<AuctionItem> GetLiveAuctionItems(){
repository.Query<AuctionItem>().Where(IsInActiveAuction()
}
public static Expression<Func<AuctionItem, bool>> IsInActiveAuction()
{
var now = SystemTime.Now();
var expression = PredicateBuilder.True<AuctionItem>();
return expression.And
(x => x.Lots.Any(
z => z.Auction.StartTime < now && z.Auction.EndTime > now && !z.DateWithdrawn.HasValue
&& z.DateApproved.HasValue));
}
我意識到這將創建子查詢,但是當我嘗試使用queryover創建我得到的錯誤,說明需要預測。
任何幫助,非常感謝。
非常感謝。我問了這個問題後,我已經意識到,我的查詢生成連接,而是我應該使用ID等子查詢等。 – Richard