views:

13

answers:

1

My project is C# and uses CastleProject ActiveRecord on MS SQL Server database.

I need to retrieve N consequent items from the database, sorted by some criteria, started from some value.

Example: I have a lot of messages in some table, where message has ID, time and text. I'd like to retrieve messages with position from 100 to 120, when they are sorted by time.

I cannot read all messages, and then sort and find on a client because there may be many messages in database (say it, a million of).

Is it possible to achieve with ActiveRecord means or only with stored procedures on SQL Server?

A: 

Assuming your AR class is MyItem and it inherits ActiveRecordBase<T>:

MyItem[] items = MyItem.SlicedFindAll(100, 20, new[] {Order.Asc("time")});
Mauricio Scheffer
Thanks - I actually wanted to ask another question:) Will open new entry.
Alex
Posted new question - http://stackoverflow.com/questions/3709707/how-to-determine-order-number-of-an-item-in-sorted-table. Please answer if you have any ideas. Thank you!
Alex

related questions