I am using linq to nhibernate to query data from large table. I am trying to limit my data query and get only last 1000 rows and only then make filtering, sorting and pagin.
When i try to use .Take() i got an error:
unable to locate HQL query plan in cache; generating (.Count[X4Data.Entity.IEventView](.OrderBy[X4Data.Entity.IEventView,System.DateTime](.Take[X4Data.Entity.IEventView](.Where[X4Data.Entity.IEventView](NHibernate.Linq.NhQueryable`1[X4Data.Entity.IEventView], Quote((x, ) => (Equal(x.DeviceId, p1))), ), p2, ), Quote((c5d4d87c-87ba-4e91-9652-bcdc87e3f0ba, ) => (c5d4d87c-87ba-4e91-9652-bcdc87e3f0ba.AtmTime)), ), ))
My code:
query = query.Take(rowCount);
query = query.ApplyFiltering(cmd, binder);
query = query.ApplySorting(cmd, binder);
binder.TotalCount = query.Count();
query = query.ApplyPaging(cmd);
Thanks a lot and sorry for my bad english
Try:
query.OrderByDescending(criteria).Take(rowCount).OrderBy(criteria)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With