Here is my class design
All I want is to get list of flytoys for a purchase order
- filter on customer name
- get the oldest purchase order
After trying many various methods, here is the code snippet that worked for me:
public FlyToy[] GetPendingToys(int Count) { using (var session = OpenSession()) { PurchaseOrder po = null; FlyToy toy = null; QueryOversubQuery = QueryOver.Of (() => po) .SelectList(list => list .SelectGroup(() => po.Toy.ID) .SelectMin(() => po.OrderDate)) .Where(Restrictions.EqProperty( Projections.Property(() => po.Toy.ID), Projections.Property(() => toy.ID))) .Where(p => p.CustomerName == "Saif"); var mainQuery = QueryOver.Of(() => toy) .Fetch(t => t.Discount).Eager .WithSubquery.WhereExists(subQuery).Take(Count); IList results = mainQuery.GetExecutableQueryOver(session) .List (); FlyToy[] FlyToys = results.ToArray(); return FlyToys; } }
Be nice to nerds. Chances are you'll end up working for one.
- Charles Sykes
Thanks ...
ReplyDeleteGreat Article
ReplyDeleteASP.NET MVC Training
Online MVC Training
Online MVC Training India
Dot Net Training in Chennai
.Net Online Training
.net training online
Dot Net Online Training
C# Training