From: Lee T. (JIRA) <nh...@gm...> - 2011-04-19 07:56:26
|
First/FirstOrDefault Doesn't Work --------------------------------- Key: NH-2656 URL: http://216.121.112.228/browse/NH-2656 Project: NHibernate Issue Type: Bug Components: Linq Provider Affects Versions: 3.1.0 Reporter: Lee Timmins I have the following tests: [TestMethod] public void First() { var result = _session.Query<Post>() .OrderBy(p => p.Date) .First(p => p.Comments.Count == 1); Assert.AreEqual(1, result.PostID); } [TestMethod] public void FirstOrDefault() { var result = _session.Query<Post>() .OrderBy(p => p.Date) .FirstOrDefault(p => p.Comments.Count == 1); var result2 = _session.Query<Post>() .OrderBy(p => p.Date) .FirstOrDefault(p => p.Comments.Count == 10); Assert.AreEqual(1, result.PostID); Assert.IsNull(result2); } They both worked fine in the old Linq provider (changing Query to Linq) but in version 3.1 it throws the error: Test method NHibernate3_1.UnitTest.First(OrDefault) threw exception: System.InvalidOperationException: Sequence contains no elements -- 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 |
From: Lee T. (JIRA) <nh...@gm...> - 2011-04-19 08:04:33
|
[ http://216.121.112.228/browse/NH-2656?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20918#action_20918 ] Lee Timmins commented on NH-2656: --------------------------------- Please note that i should have put the priority as Major as this issue is abit of a show stopper for me and i'm sure many others. Since my last bug was resolved so quickly i have added a few of my other edge cases to help make the NHibernate Linq provider as good as possible. Also note that the same issue arrises when using First/FirstOrDefault within a where clause, see the following tests: [TestMethod] public void Where_First() { var result = _session.Query<Post>() .Where(p => p.Comments.OrderBy(c => c.CommentID).First().IsSpam) .ToList(); Assert.AreEqual(2, result.Count); } [TestMethod] public void Where_FirstOrDefault() { var result = _session.Query<Post>() .Where(p => p.Comments.OrderBy(c => c.CommentID).FirstOrDefault(c => c.IsSpam).CommentID == 1) .ToList(); var result2 = _session.Query<Post>() .Where(p => p.Comments.OrderBy(c => c.CommentID).FirstOrDefault(c => c.Type == CommentTypes.Anonymous) == null) .ToList(); Assert.AreEqual(1, result.Count); Assert.AreEqual(3, result2.Count); } While these tests didn't pass in the old provider either it would be great if the new provider supported them. Thanks > First/FirstOrDefault Doesn't Work > --------------------------------- > > Key: NH-2656 > URL: http://216.121.112.228/browse/NH-2656 > Project: NHibernate > Issue Type: Bug > Components: Linq Provider > Affects Versions: 3.1.0 > Reporter: Lee Timmins > > I have the following tests: > [TestMethod] > public void First() { > var result = _session.Query<Post>() > .OrderBy(p => p.Date) > .First(p => p.Comments.Count == 1); > Assert.AreEqual(1, result.PostID); > } > [TestMethod] > public void FirstOrDefault() { > var result = _session.Query<Post>() > .OrderBy(p => p.Date) > .FirstOrDefault(p => p.Comments.Count == 1); > var result2 = _session.Query<Post>() > .OrderBy(p => p.Date) > .FirstOrDefault(p => p.Comments.Count == 10); > Assert.AreEqual(1, result.PostID); > Assert.IsNull(result2); > } > They both worked fine in the old Linq provider (changing Query to Linq) but in version 3.1 it throws the error: > Test method NHibernate3_1.UnitTest.First(OrDefault) threw exception: > System.InvalidOperationException: Sequence contains no elements -- 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-30 18:13:47
|
[ http://216.121.112.228/browse/NH-2656?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21232#action_21232 ] Fabio Maulo commented on NH-2656: --------------------------------- If you really want "make NHibernate Linq provider as good as possible" please provide a directly usable test case. http://nhforge.org/blogs/nhibernate/archive/2008/10/04/the-best-way-to-solve-nhibernate-bugs-submit-good-unit-test.aspx > First/FirstOrDefault Doesn't Work > --------------------------------- > > Key: NH-2656 > URL: http://216.121.112.228/browse/NH-2656 > Project: NHibernate > Issue Type: Bug > Components: Linq Provider > Affects Versions: 3.1.0 > Reporter: Lee Timmins > > I have the following tests: > [TestMethod] > public void First() { > var result = _session.Query<Post>() > .OrderBy(p => p.Date) > .First(p => p.Comments.Count == 1); > Assert.AreEqual(1, result.PostID); > } > [TestMethod] > public void FirstOrDefault() { > var result = _session.Query<Post>() > .OrderBy(p => p.Date) > .FirstOrDefault(p => p.Comments.Count == 1); > var result2 = _session.Query<Post>() > .OrderBy(p => p.Date) > .FirstOrDefault(p => p.Comments.Count == 10); > Assert.AreEqual(1, result.PostID); > Assert.IsNull(result2); > } > They both worked fine in the old Linq provider (changing Query to Linq) but in version 3.1 it throws the error: > Test method NHibernate3_1.UnitTest.First(OrDefault) threw exception: > System.InvalidOperationException: Sequence contains no elements -- 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 |