在执行以下查询时,我在 InnerException 中收到错误
{"Incorrect syntax near 'OFFSET'. Invalid usage of the option NEXT in the FETCH statement. Incorrect syntax near the keyword 'AS'. Incorrect syntax near 'OFFSET'. Invalid usage of the option NEXT in the FETCH statement. Incorrect syntax near the keyword 'AS'. Incorrect syntax near 'OFFSET'. Invalid usage of the option NEXT in the FETCH statement. Incorrect syntax near the keyword 'AS'."}
C#代码:
var db = new DigilibEntities();
List<title> titles = new List<title>();
titles = db.titles
.Include("themes")
.Include("subjects")
.Include("grades")
.Where(x => x.themes.Count() == 0 ||
x.subjects.Count() == 0 ||
x.grades.Count() == 0)
.OrderBy(x => x.id)
.Skip(10)
.Take(10)
.ToList();
最佳答案
默认情况下,EF 将使用 FETCH 和 OFFSET 语法进行分页。旧版本的 SQL Server 不支持此语法。您需要将 ProviderManifestToken
设置为 2008,以便 EF 生成旧的 2008 风格语法。
A breaking change in Entity Framework 6.1.2 when using EDMX and SQL Server 2008/2005
关于c# - Skip and Take 在 Entity Framework 中生成异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43322641/