Fredrik Forssen - 89 - Jun 9, 2014

Has anyone attempted to do some sort of paging (Limit/Offset) with JoinSqlBuilder? I can’t seem to find any way of doing so, but it seems like a very basic thing that you would want to do so I’m wondering if I’m just blind and missing something?

Unfortunately JoinSqlBuilder is an external SqlBuilder contributed by the community so it’s not integrated with the rest of OrmLite. Just had a look and it doesn’t look like Limit/Offset is supported. If you can add a feature request or submit an Issue, I can look at what it would take to add support for it.

Fredrik Forssen:

The easy solution here would of course be to just append the paging to the resulting query, but since I’m dealing with SQL Server 2008 here which doesn’t have any sort of sane syntax for paging in the first place this becomes very hard and seems to require me to drop all JoinSqlBuilder usage in the first place, which would be sad because I like having a strongly typed class to prevent me from doing stupid mistakes when writing code :frowning:

I’ve re-factored the SqlExpression and JoinSqlBuilders so they have some re-use around the Limit/Offset support which is now in MyGet: https://github.com/ServiceStack/ServiceStack/wiki/MyGet

Some tests showing its usage is at:
https://github.com/ServiceStack/ServiceStack.OrmLite/blob/master/tests/ServiceStack.OrmLite.Tests/Expression/SqlExpressionTests.cs#L118

Fredrik Forssen:

Demis, thank you so much, you and servicestack are completely amazing! :slight_smile: