Reputation: 21
How can i write the code for the below query in using sqlkata for sqlserver in c#?
SELECT [t0].Region
FROM ((select * from [dbo].Demo_ReportData )) AS [t0]
GROUP BY [t0].Region
ORDER BY [t0].Region ASC
offset 0 rows fetch next 50 rows only;
Upvotes: 2
Views: 1049
Reputation: 21462
To use the offset fetch
syntax you have to set the UseLegacyPagination
to false on the SqlServerCompiler
.
var compiler = new SqlServerCompiler { UseLegacyPagination = false };
var innerQuery = new Query("Demo_ReportData");
var query = new Query().From(innerQuery.As("t0"))
.GroupBy("Region")
.OrderBy("Region")
.Take(50);
var result = compiler.Compile(query);
var sql = result.Sql;
var bindings = result.Bindings;
Upvotes: 1