2

如何在 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;
4

1 回答 1

1

要使用offset fetch语法,您必须在.UseLegacyPaginationSqlServerCompiler

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;
于 2020-02-03T13:41:54.927 回答