>> > currentSession.Query<T>().Skip(bigNumber).Count(), and bigNumber large >> > enough so that after the method Skip executed resulting sequence >> > contains 0
What happens when NHibernate processes this is that, in effect, the expression is reordered so the SQL that is generated actually performs the count before the skip. This is a flaw in NHibernate. In fact, you should get the exception already when bigNumber is greater than 0, since the SQL with the count will only generate one row. On the other hand, this seems like a rather unusual query - why do you need it? /Oskar 2013/1/13 NHJunior <[email protected]>: > NHVersion 3.3.2GA (3.3.2.4000 the number specified in the properties of the > assembly file, but for some reason specified in the Visual Studio > 3.3.1.4000) > > Message: > Index is outside the range. Index must be a positive number and its size > must not exceed the size of the collection. > Parameter name: index > (Original text: Индекс за пределами диапазона. Индекс должен быть > положительным числом, а его размер не должен превышать размер коллекции. > Имя параметра: index) > > Stack trace: > в System.ThrowHelper.ThrowArgumentOutOfRangeException() > в > System.Collections.Generic.List`1.System.Collections.IList.get_Item(Int32 > index) > в NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression > nhLinqExpression, IQuery query, NhLinqExpression nhQuery) > в NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression) > в NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression > expression) > в System.Linq.Queryable.Count[TSource](IQueryable`1 source) > в MyCompany.Shop.Tests.Application.ProductServiceTest.GetNewProducts() в > d:\Visual Studio > 2010\Projects\Shop\Tests.Application\ProductServiceTest.cs:строка 86 > > > > суббота, 12 января 2013 г., 23:39:52 UTC+2 пользователь Oskar Berggren > написал: >> >> I don't see any conceptual reason for why that query shouldn't work. >> >> Please never state an exception without the message and 5-10 lines of >> the stacktrace, as this is usually vital to understand the issue. >> >> /Oskar >> >> >> 2013/1/12 NHJunior <[email protected]>: >> > Good day. >> > If i in my project execute code >> > currentSession.Query<T>().Skip(bigNumber).Count(), and bigNumber large >> > enough so that after the method Skip executed resulting sequence >> > contains 0 >> > items, i get exception ArgumentOutOfRangeException. >> > An exception occurs only when using Skip and then Count and parameter >> > bigNumber is that the resulting sequence of 0 items. If any other >> > methods >> > called between Skip and Count and resulting sequence contain 0 items an >> > exception also occurs. If Skip not called when Count working well on >> > sequence with 0 items. >> > This is a problem NH or I misunderstood its use? >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups >> > "nhusers" group. >> > To view this discussion on the web visit >> > https://groups.google.com/d/msg/nhusers/-/2b68UKBoKisJ. >> > 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. > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/nhusers/-/j33KDk_YwS0J. > > 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. -- 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.
