Select Top N records with Subsonic 3

subsonicsubsonic3

I'm using Subsonic 3.0.0.3 for a new project and on one of my pages I'm wanting to display only 5 records that are the top 5 read records. My SQL select statement is

select top(5) * from myTable order by reads desc

Is this possible to do with ActiveRecord? If it is I haven't came across how yet.

Jon

Best Answer

You can use Take to select a limited number of items for example:

IQueryable<myTable> topFive = myTable.All()
  .OrderByDescending(table => table.reads)
  .Take(5);