Please direct such issues to the NHUSERS group at http://groups.google.com/group/NHUSERS
Steve Bohlen [email protected] http://blog.unhandled-exceptions.com http://twitter.com/sbohlen On Tue, Apr 3, 2012 at 5:33 AM, pw-develop <[email protected]> wrote: > Hello, we have two problems with the clause ToFuture (). > Our schenario is this: > SQL Server 2008 R2, > C #. NET4.0, > NHibernate 3.2.0.4000 > > The query that we are looking at is this: > using (var session = GetNhibernateSession()) { > var pratica = session .Query<Pratica>() .Fetch(x => x.Domiciliatario) > .Fetch(x => x.Procuratore) .ToFuture() .SingleOrDefault(x => x.Id == > idPratica); > var praticaClienti = session .Query<Pratica>() .FetchMany(x => > x.Clienti).ThenFetch(k => k.Soggetto) .ToFuture() .SingleOrDefault(x => > x.Id == idPratica); > var praticaControParti = session .Query<Pratica>() .FetchMany(x => > x.Controparti) .ThenFetchMany(x => x.Avvocati) .ToFuture() > .SingleOrDefault(x => x.Id == idPratica); > var praticaAffidatari = session .Query<Pratica>() .FetchMany(x => > x.Affidatari) .ToFuture() .SingleOrDefault(x => x.Id == idPratica); > var praticaEventi = session .Query<Pratica>() .FetchMany(x => x.Eventi) > .ThenFetch(k => k.AttivitaCollegata) .ToFuture() .SingleOrDefault(x => x.Id > == idPratica); > var praticaAttivita = session .Query<Pratica>() .FetchMany(x => > x.Attività ) .ToFuture() .SingleOrDefault(x => x.Id == idPratica); > var praticaNoteContabili = session .Query<Pratica>() .FetchMany(x => > x.NoteContabili) .ToFuture() .SingleOrDefault(x => x.Id == idPratica); > var praticaFondoSpese = session .Query<Pratica>() .FetchMany(x => > x.AccontiFondoSpese) .ToFuture() .SingleOrDefault(x => x.Id == idPratica); > return pratica; > } > > The problems are these: > First, the SQL Profiler we saw that the queries are generated on the > database as theyare defined rather than optimizing the request as we seem > to have understood by reading this blog > http://ayende.com/blog/3979/nhibernate-futures. > Second, using database with different data, but with the same structure, > in some casesare generated many more queries, 49, instead of 11. > > Tanks in advance. >
