> Can you try without it? Not sure to understand you. As I wrote, I don't use ToList() because I don't want to load the whole collection in memory. This is here that the problem occurs. First() does not return the right item. With ToList(), the query is executed first which gives a collection in memory, then Skip and First operate in memory and work well.
Nicolas On Oct 28, 9:05 pm, Mohamed Meligy <[email protected]> wrote: > I think the blog post you referenced is a different case. > > I commented on the post, here is my comment: > > From my uderstanding of LINQ in general, I think there is a mistake in the > above code. > > A typical ue of the code is: > > using (var session = sessionFactory.OpenSession()) > { > var nhQueryable = session.Linq< Invoice >(); > nhQueryable = nhQueryable.Expand("Items"); > var invoice = nhQueryable.Where(i => i.Id == id).First(); > > } > > Note the line: > > nhQueryable = nhQueryable.Expand("Items"); > > This is how IQueryable in general usually works. > > Can you try and tell me ? > > Not sure about your case though, but from my yunderstanding of LINQ in > general as well, I believe that calling ToList() EXECUTES the LINQ query, > and all the other methods (Skip, First) are LINQ To Objects performed on > the returned List (because it's an IEnumerable). *Can you try without it??* > > Regards, > > -- > Mohamed Meligy > Information Analyst (.Net Technologies) – Applications Delivery - TDG > Injazat Data Systems > P.O. Box: 8230 Abu Dhabi, UAE. > > Phone: +971 2 6992700 > Direct: +971 2 4045385 > Mobile: +971 50 2623624, +971 55 2017 621 > > E-mail: [email protected] > Weblog:http://weblogs.asp.net/meligy > > On Thu, Oct 29, 2009 at 12:07 AM, NickNH <[email protected]> wrote: > > > Hi, > > > I wrote something like this: > > > queryableCollection.Skip(1).First(); > > > The issue is with First() that will totally ignore the skip and always > > return the first item of the original collection. In VS with the > > debugger, what is returned by Skip is correct. > > So this is a major issue. My workaround is to write: > > > queryableCollection.ToList().Skip(1).First(); > > > which bypasses LinqToNH but that is a hit on the perf... > > > I also found it mentioned here: > > >http://marcinbudny.blogspot.com/2009/10/linq-to-nhibernate-first-bug.... > > > Nicolas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
