2

在当前范围或上下文中无法解析“fieldName”。确保所有引用的变量都在范围内,加载了所需的模式,并且正确地引用了命名空间。

当我_data在控制器中声明时出现该消息:

string orderBy = sidx + " " + sord;
IQueryable<Table> _data;
_data = entities.Table.OrderBy(orderBy).Skip(skip).Take(take);

有什么帮助吗?

4

2 回答 2

3

感谢您的回答,现在我意识到了......问题是因为sidx我从fieldName标题 jqgrid 中获得的参数无法识别表名。然后我尝试这样做,现在它解决了:)

添加it.到订单变量:

string orderBy = "it."+ sidx + " " + sord; IQueryable<Table> _data;
_data = entities.Table.OrderBy(orderBy).Skip(skip).Take(take);
于 2012-08-29T03:13:32.603 回答
1

The most probable cause is that the orderBy expression you have generated references the field which is not available in the Table - just set a breakpoint in this line and check what value it has.

One important thing here is that in case of jqGrid (you have tagged your question with jqGrid) there are some inconsistencies in what is being send as sidx. Most of the time it is the index from colModel but sometimes (for example when grouping is enabled) it can be name.

于 2012-08-27T07:28:46.953 回答