From: Krzysztof K. (J. <nh...@gm...> - 2011-05-16 03:28:45
|
[ http://216.121.112.228/browse/NH-2706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21080#action_21080 ] Krzysztof Koźmic commented on NH-2706: -------------------------------------- I think I found a workaround for now. It seems to be working properly if I change the subselect to: where (from personBar in _session.Query<PersonBars>() where personBar.Person.Id == _personId select personBar).Any(pb => pb.Bar == foo.Bar) > subselect in LINQ query with Contains clause produces wrong SQL > --------------------------------------------------------------- > > Key: NH-2706 > URL: http://216.121.112.228/browse/NH-2706 > Project: NHibernate > Issue Type: Bug > Components: Linq Provider > Affects Versions: 3.1.0 > Reporter: Krzysztof Koźmic > Priority: Critical > > I was trying to execute the following query > return (from foo in _session.Query<Foo>() > where (from personBar in _session.Query<PersonBars>() > where personBar.Person.Id == _personId > select personBar.Bar).Contains(foo.Bar) > orderby foo.FooNumber > select new SomeProjection( > foo.Id, > foo.A, > foo.B, > foo.Bar.Id, > foo.Bar.Description)).ToList(); > basically the goal was to get all Foos with Bar that given user of the app has Bar for too. > now the part of the SQL generated that has a bug in it looks kind of like this (sorry for obscuring it): > where some clauses > and (exists (select bar_.ID > from PERSON_BAR pb > joins to bar > where some other clauses here > and pb.ID = foo0_.BAR_ID)) > Notice the last line which should say > pb.BAR_ID = foo0.BAR_ID > that's the bug. > Hope that helps. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |