如何在 c# 中使用 sqlkata for sqlserver 编写以下查询的代码?
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;
如何在 c# 中使用 sqlkata for sqlserver 编写以下查询的代码?
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;
要使用offset fetch
语法,您必须在.UseLegacyPagination
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;