How do I fix this error: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

How do I fix this error: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

我想根据用户从下拉列表中选择的排序标准对数据列表的结果进行排序,但出现此错误:

Only assignment, call, increment, decrement, and new object expressions can be used as a statement

我已经阅读了这个网站上的很多帖子,但我的理解还不够好,无法将我找到的解决方案与我的具体问题联系起来。

任何人都可以解释为什么我在这种情况下会收到此错误以及如何解决它吗?

我的Html查看

        @Html.DropDownList("SortParm", Model.ReverseMonthsLists(),
            new { @onchange = "CallChangefunc(this.value)" })
        < script >
        function CallChangefunc(sortKey) {
        window.location.href = "/dashboard/Report_Performance?id=" + sortKey;
        }
        </ script >

我的控制器

public ActionResult Report_Performance(string id, string sortKey)
{
    DateTime newDate = DateTime.Now.Date.AddMonths(-1);
    if (id != null)
        newDate = DateTime.Parse(id);
    var aVar = Models.Reporting.ListingStatsReportingViewModel.GetStats(userCurrentService.CompanyId.Value, Models.Reporting.DateTimePeriod.Monthly, newDate);
    aVar.CurrentListingStats.OrderByDescending<>;    //<- PROBLEM IS HERE
    ViewBag.SelectedItem = id;
    ViewBag.SortParm = sortKey;
    return this.View(aVar);
}

我在控制器中尝试了这些语句,但都没有成功:

        //aVar.CurrentListingStats.OrderBy<>;
        //aVar.CurrentListingStats.OrderBy<sortKey>;
        //aVar.CurrentListingStats.OrderBy < Models.Reporting.ListingStatsReportingViewModel.GetStats(userCurrentService.CompanyId.Value, Models.Reporting.DateTimePeriod.Monthly, sortKey);
        //aVar.CurrentListingStats.OrderByDescending<>;

使用

 var aVar = Models.Reporting.ListingStatsReportingViewModel.GetStats(userCurrentService.CompanyId.Value, Models.Reporting.DateTimePeriod.Monthly, newDate);
aVar.CurrentListingStats.OrderByDescending(x=>x.sortKey); 

当您在具有统计信息列表的 Var 变量中获取数据时(aVar.CurrentListingStats),之后当您使用 lembda 表达式对其进行排序时,因此在 Linq Expression 中需要一个参数,其中的键值数据将被排序显示我们需要提供一个列名来对数据进行排序。

在上面的问题中,用户将其用作语句而不是方法