Read N consequent items by ActiveRecord

本小妞迷上赌 提交于 2020-01-25 13:07:27

问题


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?


回答1:


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

MyItem[] items = MyItem.SlicedFindAll(100, 20, new[] {Order.Asc("time")});


来源:https://stackoverflow.com/questions/3707200/read-n-consequent-items-by-activerecord

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!