分页查询如下
var ctx = fsql.CreateDbContext();
var students = ctx.Set<Student>()
.Where(t => t.Grade == 1)
.OrderBy(t => t.Name)
.Page(query.page, query.rows)
.ToList();
// SELECT * FROM student WHERE grade = 1 ORDER BY name LIMIT 10 OFFSET 0;
每页的查询结果本来应该互不相同,但实践中发现查询结果会在不同的页中重复出现
排序字段Student.Name有很多重复的值,排序结果不稳定
增加排序字段Id
var students = ctx.Set<Student>() .Where(t => t.Grade == 1) .OrderBy(t => t.Name) .OrderBy(t => t.Id) .Page(query.page, query.rows) .ToList();
// SELECT * FROM student WHERE grade = 1 ORDER BY name, id LIMIT 10 OFFSET 0;
标签:OrderBy,分页,FreeSql,ctx,查询,var,query,Name From: https://www.cnblogs.com/uta-red/p/18325713