A quick draft with a clear how to steps. The first part, the subquery
could look like this:
QueryOver<Lot> subQuery =
QueryOver.Of<Lot>(() => lot)
// Lot WHERE
.WhereRestrictionOn(() => lot.DateWithdrawn).IsNull
.AndRestrictionOn(() => lot.DateApproved).IsNotNull
// Auction JOIN
.JoinQueryOver<Auction>(l => l.Auction, () => auction)
// Auction WHERE
.Where(() => auction.StartTime < now)
.Where(() => auction.EndTime > now)
// AuctionItem.ID SELECT == projection
.Select(Projections.Property(() => lot.AuctionItem.ID))
;
So, this will return the AuctionItem.ID
, which does meet our seraching criteria. And we can use it like this:
AuctionItem auctionItem = null;
var query = session.QueryOver<AuctionItem>(() => auctionItem)
.WithSubquery
.WhereProperty(() => auctionItem.ID)
.In(subQuery)
...