我已经咨询了Warning in Resharper "Return value of pure method is not used"帖子但未找到解决方案
看看我的代码
var listDetail = (from p in Expense.GetAll()
where p.Group == "001"
select new ExpenseViewModel()
{
ExpenseC = p.ExpenseC,
Group = p.Group,
Cost = p.Cost,
}).ToList();
listDetail.OrderBy(p => p.ContainerSizeI); //warning displayed at OrderBy with content "return value of pure method not used"
因此,listDetail
变量没有按照我想要的升序排序
答案 0 :(得分:2)
您需要将OrderBy移动到您的方法链中。
var listDetail = (from p in Expense.GetAll()
where p.Group == "001"
select new ExpenseViewModel()
{
ExpenseC = p.ExpenseC,
Group = p.Group,
Cost = p.Cost,
})
.OrderBy(p => p.ContainerSizeI)
.ToList();