Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to limit TOP rows returned by OrmLite select using Linq Expression?

It seems like OrmLite Select(predicate) function it brings back everything in the where clause (across the network) and then applies the .Take(x) on top of that.

I need a way to only bring back the TOP x so the results are faster and use less bandwidth.

Is there a way to limit TOP rows returned by OrmLite select (using a Linq Expression)?

like image 795
nerfduster Avatar asked Feb 11 '14 04:02

nerfduster


1 Answers

Limit and Offset support is available using the Limit() expression, e.g::

Take 10 Rows

var rows = db.Select<Table>(q => q.Where(x => x.Name != null).Limit(10));

Skip 5 Rows, Take 10

var rows = db.Select<Table>(q => q.Where(x => x.Name != null).Limit(5,10));
like image 173
mythz Avatar answered Oct 14 '22 14:10

mythz