Hey guys, there is a way to implement inner join with Fetch: https://github.com/gkarwchan/nhibernate-linq-innerjoin-fetch
I've just download the repository, change to the current version of nhibernate (which is hardcoded) and reference the assembly on my project. Now I have InnerFetch/ThenInnerFetch methods. Would be great to have these methods on the next version of NHibernate. The Fetch just generates the Left join. Thank you. On Wed, Mar 15, 2017 at 3:07 PM, Felipe Oriani <[email protected]> wrote: > Guys, just a last question about nhibernate querying/fetching. > > When we use Linq to NHibernate, there are methods to solve the problem: > Fetch and ThenFetch. For sample: > > var list= session.Query<Product>().Fetch(x => x.Category).ToList(); > > These methods generate a *LEFT OUTER JOIN* for each relation. Is it the > default behaviour? Or is there any way to tell to linq when use *LEFT *or > *INNER* join? > > I know in QueryOver we can use Left / Inner / Right, but we have complex > queries with Linq. > > Thank you. > > > > > > > > > > > > On Wed, Mar 15, 2017 at 1:41 PM, Felipe Oriani <[email protected]> > wrote: > >> Yes, I know I can use Select method to make a projection what I want, I >> ask about something more simple. >> >> Thank you. >> >> On Wed, Mar 15, 2017 at 12:34 PM, Ricardo Peres <[email protected]> >> wrote: >> >>> Sorry, "You can". >>> >>> RP >>> >>> >>> On Wednesday, March 15, 2017 at 3:34:41 PM UTC, Ricardo Peres wrote: >>>> >>>> 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 < >>>>> [email protected]> 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 [email protected]. >>>>>> To post to this group, send email to [email protected]. >>>>>> Visit this group at https://groups.google.com/group/nhusers. >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> ______________________________________ >>>>> Felipe B Oriani >>>>> [email protected] >>>>> >>>> -- >>> 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 [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at https://groups.google.com/group/nhusers. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> ______________________________________ >> Felipe B Oriani >> [email protected] >> > > > > -- > ______________________________________ > Felipe B Oriani > [email protected] > -- ______________________________________ Felipe B Oriani [email protected] -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
