我对 EF 有一些问题。所以,我的 mysql 表中有 1000000 条记录。我需要有限制的查询。例如,我使用跳过 50000 进行查询
var listRoutes = (from c in context.Routes
where c.Alias != ""
orderby c.Alias ascending
select c).Skip(50000).Take(500).ToList();
listRoutes 有 500 条记录。如果我用跳过 100000 查询
var listRoutes = (from c in context.Routes
where c.Alias != ""
orderby c.Alias ascending
select c).Skip(100000).Take(500).ToList();
或者
List<Route> listRoutes = context.Routes.Where(x => x.Alias != "").OrderBy(a => a.Alias).Skip(100000).Take(500).ToList();
listRoutes 有 0 条记录。但是,如果我通过跳过 100000 或更多来查询
List<Route> listRoutes = context.Database.SqlQuery<Route>("SELECT * FROM testcmsdatamap.routes WHERE alias != '' order by alias asc limit 500000, 500").ToList();
listRoutes 也有 500 个...有什么问题?