Use can, obviously, use projections and only fetch the properties you are interested in. Something like;
var products = Session.Query<Product>().Select(p => new { p.Id, CategoryName = p.Category.Name <http://p.category.name/> }).ToList(); On Wednesday, March 15, 2017 at 12:35:16 PM UTC, Felipe Oriani wrote: > > Hey guys, I am looking at the problem for "select n+1" queries. It scare > us when I a session with more than 10 queries more than 100 in some cases > haha). Some refactoring to do. > > Sometimes I just need a string property to fill a column on the grid and > using `Fetch` extension method NHibernate fill the entire entity on the > relation.* Is there any way to tell to NHibernate fill up just a column I > need, without using the `Select` (from Linq) or `SelectLitst` (from > QueryOver)?* Something like this: > > var products = Session.Query<Product>().FetchProperty(p => p.Category.Name > ).ToList(); > > @Nestor, these cases are not huge tables. it will not pass more than 1000 > records and some filters applied. > > Thank you Guys > > > On Wed, Mar 15, 2017 at 5:15 AM, Nestor Andres Rodriguez < > nest...@gmail.com <javascript:>> wrote: > >> Hi Felipe, >> >> Joins may be expensive. But what is really important prior to any >> optimization is to know how the data in this query behaves (reads, writes), >> how often this query will be executed, how important is this query for the >> business and customers, would it be a problem if it takes a few minutes , >> how up-to-date should be the information, seconds, minutes, hours. >> >> If this query needs for example to be executed in few milliseconds, and >> you have million of records on each of the 6 tables then probably you >> would like to avoid calculating the joins every time, so you may create a >> denormalised table which is updated regularly using some triggering >> mechanism, the downside is that you have to maintain yet another table and >> a trigger mechanism. >> >> At the end everything has a cost, and you need to identify if it worth >> it. If nobody complains and you do not see a good reason to optimize it, >> just do not care about that. >> >> Cheers, >> Nestor >> >> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to nhusers+u...@googlegroups.com <javascript:>. >> To post to this group, send email to nhu...@googlegroups.com >> <javascript:>. >> Visit this group at https://groups.google.com/group/nhusers. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > ______________________________________ > Felipe B Oriani > felipe...@gmail.com <javascript:> > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+unsubscr...@googlegroups.com. To post to this group, send email to nhusers@googlegroups.com. Visit this group at https://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.