> from timeHeader in metaData.NonPresentTimeHeader > where timeHeader.Id == 6 > join time in metaData.NonPresentTime on timeHeader.Id equals time.HeaderId > into timeJoin > from joinedTime in timeJoin.DefaultIfEmpty() > select joinedTime
> What might be a solution is to add a 'jointype' to the groupjoin class of > re-linq > and switch it to 'left join' when you handle the p=>DefaultIfEmpty() > construct of a re-linq tree. Hi Frans, we could transform simple left-join-via-DefaultIfEmpty to left join clauses in re-linq's QueryModel, but that would be a very simplistic solution that could not support any but the most straightforward LINQ clauses. (i.e. only those where someone implements left join as they found out via Google, but for instance not any scenario where the query further references the intermediate join clause (timeJoin in your sample). We think that DefaultIfEmpty is best solved in each back-end individually, but of course nothing stops anyone from extending the front-end to create that kind of QueryModel via an optional transformation step. Just be aware that this only takes you so far, it would probably result in the LINQ provider rejecting every use of DefaultIfEmtpy in joins that cannot be reduced to that pattern. Cheers, Stefan > -----Original Message----- > From: [email protected] [mailto:nhibernate- > [email protected]] On Behalf Of Frans Bouma > Sent: Monday, August 30, 2010 8:53 PM > To: [email protected] > Subject: RE: [nhibernate-development] Re: DefaultIfEmpty outer join > support for NH3 > > > DefaultIfEmpty is probably top of the features that I'd like to get > added. > > I suspect a naive approach won't be too hard, and will probably nail > a > large > > %age of use-cases. A full implementation will be, as suggested by > Frans, > a > > serious undertaking and I suspect isn't worth the effort. However, > as an > > unpaid volunteer, I'm not going to commit to a date for even the > naive > > implementation :) I will try my best though! > > It might be simpler with re-linq's front end. I was trying it out > on > saturday, and I saw this: > query: > [Test] > public void RelinqTest1() > { > using(DataAccessAdapter adapter = new DataAccessAdapter()) > { > LinqMetaData metaData = new LinqMetaData(adapter); > var q = from reason in metaData.Reason > join time in > ( > from timeHeader in > metaData.NonPresentTimeHeader > where timeHeader.Id == 6 > join time in > metaData.NonPresentTime on timeHeader.Id equals time.HeaderId into > timeJoin > from joinedTime in > timeJoin.DefaultIfEmpty() > select joinedTime > ) on reason.Id equals time.ReasonId > into reasonJoin > from joinedReason in > reasonJoin.DefaultIfEmpty() > select new > { > ReasonID = reason.Id, > Reason = reason.Reason, > HeaderID = joinedReason.HeaderId ?? > -1, > TimeID = joinedReason.Id, > Notes = joinedReason.Notes, > DateStart = joinedReason.DateStart, > DateEnd = joinedReason.DateEnd > }; > var parser = new QueryParser(new > ExpressionTreeParser(MethodCallExpressionNodeTypeRegistry.CreateDefault > ())); > var query = parser.GetParsedQuery(q.Expression); > Console.WriteLine(query.ToString()); > } > } > > Front-end produces: > from ReasonEntity reason in > value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource2`1[AdventureWorks.Da > l.Ada > pter.EntityClasses.ReasonEntity]) > join NonPresentTimeEntity time in > { > from NonPresentTimeHeaderEntity timeHeader in > value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource2`1[AdventureWorks.Da > l.Ada > pter.EntityClasses.NonPresentTimeHeaderEntity]) > where ([timeHeader].Id = 6) > join NonPresentTimeEntity time in > value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource2`1[AdventureWorks.Da > l.Ada > pter.EntityClasses.NonPresentTimeEntity]) > on Convert([timeHeader].Id) equals [time].HeaderId into > IEnumerable`1 timeJoin > from NonPresentTimeEntity joinedTime in > { > [timeJoin] => DefaultIfEmpty() > } > select [joinedTime] > } > on Convert([reason].Id) equals [time].ReasonId into IEnumerable`1 > reasonJoin from NonPresentTimeEntity joinedReason in { > [reasonJoin] => DefaultIfEmpty() > } > select new <>f__AnonymousType101`7 > ( > ReasonID = [reason].Id, > Reason = [reason].Reason, > HeaderID = ([joinedReason].HeaderId ?? -1), > TimeID = [joinedReason].Id, > Notes = [joinedReason].Notes, > DateStart = [joinedReason].DateStart, > DateEnd = [joinedReason].DateEnd > ) > > Now, as you can see in this snippet: > > from NonPresentTimeEntity joinedTime in > { > [timeJoin] => DefaultIfEmpty() > } > > the defaultifempty is simply referring to the groupjoin object. What > might > be a solution is to add a 'jointype' to the groupjoin class of re-linq > and > switch it to 'left join' when you handle the p=>DefaultIfEmpty() > construct > of a re-linq tree. > > At least that's what I thought of when looking at it. BUt I might > overlook > things, haven't looked too deeply into re-linq. > > FB > > > > > > > On Fri, Aug 20, 2010 at 7:25 AM, Fabio Maulo <[email protected]> > wrote: > > > > > > Perhaps. > > > > > > On Fri, Aug 20, 2010 at 2:23 AM, pvginkel <[email protected]> > wrote: > > > > > > OK, this went a little bit off topic. Anyway, to get back > to > > the > > subject, I was wondering whether you agree this is a > crucial > > feature > > of the Linq provider. Maybe I'm missing the obvious, but I > do > > not see > > a different way to get outer joins to work via Linq. I > would > > offer to > > pick this up would it not be that the initial reply kind of > > scared me > > away :). > > > > In short, can we expect to get outer joins via Linq working > in > > the GA? > > > > > > On Aug 19, 9:47 pm, Fabio Maulo <[email protected]> > wrote: > > > Ok. > > > > > > P.S. perhaps somebody will implements a fix... perhaps. > > > > > > > > > > > > > > > > > > > > On Thu, Aug 19, 2010 at 3:30 PM, Frans Bouma > <[email protected]> > > wrote: > > > > > about this " it ends up with you talking me down in > some > > form or the > > > > other" > > > > > I don't know what you are talking about. > > > > > > > To help you, think REALLY HARD about the > > following: > > > > Why did you reply with 3 emails to my post, only > replying > > on my first > > > > sentence, as if I would imply anything with it instead > of > > exactly what I > > > > said. Why did you think that of me? > > > > > > > For the record, the only one who replied with > any > > real info to the > > > > topicstarter was... who? I really don't know why you > had > > to do this, I > > > > really don't. > > > > > > > FB > > > > > > > > For others matter: Ok. > > > > > > > > > > On Thu, Aug 19, 2010 at 2:00 PM, Frans Bouma > > <[email protected]> wrote: > > > > > > > > > I saw that you tried to be helpful in the > other > > part of your > > > > mail. > > > > > > > > I tried to be helpful in EVERY email > here > > and on nhusers, > > > > and > > > > > I > > > > > didn't want to imply *anything* in the 1st > > sentence I wrote. WTF is > > > > > your > > > > > problem? > > > > > > > > > What we have notice is that there is a kind > of > > "personal > > > > questions" > > > > > when > > > > > we > > > > > > are talking about our linq-provider and we > don't > > have a > > > > > "personalized > > > > > > customer service" (at least not for free). > > > > > > > > I have no idea what you mean/refer to. > > > > > > > > > Steve is part of NH's team and the Linq > provider > > is part of > > > > > NHibernate > > > > > core. > > > > > > As any other issue, even the issues related > to > > linq-provider are > > > > > solved by > > > > > > the team. > > > > > > > > > Perhaps, with his silence, Steve and the team > > altogether are > > > > trying > > > > > to say > > > > > > the same. > > > > > > > > Sorry but I have no idea what you mean, > but > > anyway, it's > > > > been > > > > > enough. Every f*cking time 'Linq' is mentioned > and > > I reply in some > > > > > form or > > > > > another, it ends up with you talking me down in > > some form or the > > > > > other. I > > > > > just try to be helpful, but I don't need this > kind > > of bickering. If > > > > > helping > > > > > out time after time ends up with some form of > > bickering, I won't > > > > > spend my > > > > > time on it anymore. Like I've said to Steve > > before, he can email me > > > > > any time > > > > > with questions about Linq and how to do things, > > but I won't reply > > > > to > > > > > linq > > > > > crap here again, as apparently you don't want > my > > help/information > > > > > about how > > > > > to deal with linq expressions and what to > expect. > > In case you don't > > > > > know, > > > > > mr. Maulo, that info is no-where to be found on > > the net nor in MS' > > > > > documentation. Only the small group on this > planet > > who have dealt > > > > > with these > > > > > miserable issues before know what to expect and > > where a solution > > > > > 'might' be > > > > > found (as the only team who managed to get it > all > > right is the Linq > > > > > to Sql > > > > > team (now abandoned) and they didn't publish > any > > of their info). > > > > > > > > FB > > > > > > > > > P.S. I'm a "little bit" more loquacious in > some > > cases > > > > > > > > > > > On Thu, Aug 19, 2010 at 11:54 AM, Frans Bouma > > <[email protected]> > > > > > > wrote: > > > > > > > > > > On Thu, Aug 19, 2010 at 7:20 AM, > Frans > > Bouma < > > > > > > [email protected]> > > > > > > > wrote: > > > > > > > > > > I don't know if Steve's still > > reading this list, > > > > > > > > > > What do you mean ? > > > > > > > > > Well, I asked in some other linq > > thread a couple of > > > > > questions > > > > > > to > > > > > > Steve, gave info about how to do > things, > > but never got a > > > > > reply (was > > > > > > in June > > > > > > or so), also all other linq related > > material is not > > > > answered > > > > > by him, > > > > > > so I > > > > > > wondered if he was still reading this > > list. I don't know > > > > how > > > > > else to > > > > > > interpret this remark, to be honest. > > > > > > > > > But that aside, sorry I tried to > be > > helpful, mr. > > > > > Maulo. > > > > > > > > > FB > > > > > > > > > -- > > > > > > Fabio Maulo > > > > > > > > -- > > > > > Fabio Maulo > > > > > > -- > > > Fabio Maulo > > > > > > > > > > -- > > Fabio Maulo > > > > > > >
