Friday 15 July 2011

How would one create this query using NHibernate QueryOver instead of Linq? -


I need to use QueryOver instead of Linq, but I am struggling to recreate the following question :

  Public IQueryable & lt; AuctionItem & gt; GetLiveAuctionItems () {repository.Query & lt; AuctionItem & gt; () IsInActiveAuction ().} Public expression of expression & lt; auctionItem, bool & gt; & gt; IsInActiveAuction () {var now = SystemTime.Now (); on expression = PredicateBuilder.True & Lt; auction item & gt; (); return expression. (X = & gt; x.Lots.Any (z = & gt; z.Auction.StartTime & lt; now & amp; amp; z.Auction.EndTime & Gt; now & amp; amp; z.DateWithdrawn.HasValue & amp; z.DateApproved.HasValue)).}   

I make this subquery but realize when I Trying to get the errors that are using the queryover using the estimates << P>

A clear

  queryover  lot> with a quick draft ; Subcacey = queryover.off  gt; ((=); many) // where lotus (= = = gt; lot.DateWithdrawn) .isNull. And rearrangement (=) & Gt; lot.DateAprproved). NotNull // Auction Addition.jointise & lt; Auction & gt; (l = & gt; L. Auction, () = & gt; Auction) // where auction. Where ((= => auction.StartTime & LT; now) .Where ((= => auction.EndTime> now) // Select AuctionItem.ID == Launch .select (est. Property ((= => lot.AuctionItem.ID));   

So, this AuctionItem The ID will return , which meets our search criteria. And we can use it like this:

  Auctions auction itam = null; Query = session.QueryOver & lt; AuctionItem & gt; ((=) AuctionItem) .WithSubquery .WhereProperty ((=) AuctionItem.ID). Its (subquery) ...    

No comments:

Post a Comment