声明后,asp.net核心ef命令无效

时间:2018-07-10 23:14:19

标签: entity-framework asp.net-core

以下内容将按我的观点按地址排序结果:

var results = _context.SiteUnit.OrderBy(x=>x.address);
return View(await results.ToListAsync());

但是,以这种方式编写并不会在我看来对结果进行排序:

var results = _context.SiteUnit;
results.OrderBy(x=>x.address);
return View(await results.ToListAsync());

有人经历过吗?我试图解决此问题,因为我需要根据选定的过滤器设置OrderBy子句的后缀。

1 个答案:

答案 0 :(得分:0)

张贴Mark G提出的对我有用的解决方案。

results = results.OrderBy(x=>x.address)