NHibernate's rock I scratched my head for a few hours looking at this code
DetachedCriteria filter = DetachedCriteria.For(typeof(Project))Wonder why I got so many sql call to the server? the domain objects in the discussion context are Project has a Type and base on selected Type a project can choices a bunch of Outputs.
DetachedCriteria q = DetachedCriteria.For(typeof(List_Output), "op")
So Project is belong to a Type [One-to-Many], and Type has many Outputs where Output belong to Many Types [Many-to-Many].
What I found and fix is Lazzzzzzzziiiiiiiiiiiiiiii :))
I forgot to tell Type to load Outputs in a Lazy way and vise versa once that done I got only one YEAH ! I mean ONE sql call to the server to get what I asked for instead of 2 + N (where N is number of relevant Outputs in a Type)
Thanks to DetachedCriteria & the Laziness until next time today magic word is "Lazy = true"