maxtoroq / DbExtensions

Data-access framework with a strong focus on query composition, granularity and code aesthetics.
https://maxtoroq.github.io/DbExtensions/
Apache License 2.0
227 stars 41 forks source link

SqlServer 2008 support in SqlSet #33

Closed cnsharp closed 9 years ago

cnsharp commented 9 years ago

I found that SqlSet.Take and Skip method are based on SQL 2012.How can I do that in SQL 2008? Thanks!

maxtoroq commented 9 years ago

I'll see what I can do. Looks similar to Oracle's paging, using ROW_NUMBER() OVER(ORDER BY ).

maxtoroq commented 9 years ago

@cnsharp SqlServer 2008 support is complete. Please checkout the master branch to try it out. You have to decorate your database class with [Provider(typeof(Sql2008Provider))] to enable it, e.g.:

[Provider(typeof(Sql2008Provider))]
class Sql2008Database : Database {
   ...
}
cnsharp commented 9 years ago

Thank you very much!You are so quickly and dedicated.I'll try it now.

cnsharp commented 9 years ago

@maxtoroq Hi Max,

Our DBA recommended a style like this which has a better performance in the middle of many pages

WITH ID AS( SELECT row_id = ROW_NUMBER() OVER(order by id DESC), id FROM dbo.tb WITH(NOLOCK) WHERE column_id = 1 ) SELECT ID.__row_id, DATA.* FROM ID INNER JOIN dbo.tb DATA WITH(NOLOCK) ON DATA.id = ID.id WHERE ID.row_id BETWEEN 5000 AND 5100 ;

I want to implement it by myself. The question is how can I pass id/primary key to SqlSet?Maybe I could add an id property to SqlSet.

What is your opinion? Thanks!

maxtoroq commented 9 years ago

@cnsharp That level of fine tuning is not supported, use SqlBuilder instead. If you have more questions please create a new issue.