OrmLite question: How to limit rows count?

951 views
Skip to first unread message

KhodeN

unread,
Mar 30, 2012, 10:18:23 PM3/30/12
to ServiceStack .NET Open Source REST Web Services Framework
I have tried to select limited count of rows with this:

var list = dbCmd.Select<AddressObject>().Take(10);

But it didn't work perfectly. It is so slow! (Common number of records
is about 11 millions)

Another way I have tried was this:

var list = dbCmd.Select<AddressObject>("SELECT TOP 10 * FROM
as_addrobj");

It was quick, but I think, that it is dirty. This way is workaround.

How to select limited count of records with correct way?

Demis Bellot

unread,
Mar 30, 2012, 10:28:43 PM3/30/12
to servic...@googlegroups.com
What RDBMS are you using?

As you should be able to use the Sql Expression below for anything but Sql Server:

var results = dbCmd.Select<Author>(q => q.Limit(10));

P.S. if it's succinct, intuitive + works it's not dirty :)

Cheers,

Artem Berezin

unread,
Mar 30, 2012, 11:26:53 PM3/30/12
to servic...@googlegroups.com
I'm using Sql Server.
Thanks for answer. It works excelent! I'm happy)

суббота, 31 марта 2012 г. 13:28:43 UTC+11 пользователь mythz написал:
What RDBMS are you using?

As you should be able to use the Sql Expression below for anything but Sql Server:

var results = dbCmd.Select<Author>(q => q.Limit(10));

P.S. if it's succinct, intuitive + works it's not dirty :)

Cheers,
Reply all
Reply to author
Forward
0 new messages