从Linq查询结果中读取数据时发生异常

时间:2018-02-08 12:23:18

标签: c# entity-framework linq

我在页面加载时遇到以下错误。当它在页面加载时命中List()方法。

请注意,我已经在下面的代码中获得了变量查询的值。

但在执行行后的其他部分:

JtableReturnTypeObj.Records = query.Skip(jtStartIndex).Take(jtPageSize).ToList();

点击catch块并显示以下错误。

  

值不能为空。
  参数名称:表达式

执行第一行后,在下面的代码中遇到错误。

public JtableListReturnType List(string Params, int jtStartIndex = 0, 
                                 int jtPageSize = 0, string jtSorting = null, 
                                 string jsonAdvancedSearchFilterCriteria = null, int? id = 0)
{
    var query = (   //Provided Linq code here // )

    if (jsonAdvancedSearchFilterCriteria != null)
    {
        var searchResult = QueryBuilder.AdvancedSearchQueryBuilder(query, 
 jsonAdvancedSearchFilterCriteria, false);
        //onloadtext party
        JtableReturnTypeObj.Records = searchResult.Skip(jtStartIndex).Take(jtPageSize).ToList();
        JtableReturnTypeObj.Result = "OK";
        JtableReturnTypeObj.TotalRecordCount = searchResult.Count();
    }
    else
    {
        JtableReturnTypeObj.Records = query.Skip(jtStartIndex).Take(jtPageSize).ToList();
        JtableReturnTypeObj.Result = "OK";
        JtableReturnTypeObj.TotalRecordCount = query.Count();
    }
}

0 个答案:

没有答案
相关问题