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 |