我正在使用jqGrid,我在使用Dynamic Linq时遇到问题。我使用NuGet安装Dynamic并添加了“using System.Linq.Dynamic;”。
使用VS 2010 Pro,MVC 3.0
这有效:
var s = context.testdata;
var c = s.Count();
c显示5136项。
但我无法使用动态方法:
var s = context.testdata.OrderBy("id asc");
我收到此错误消息:
'id' could not be resolved in the current scope or context.
Make sure that all referenced variables are in scope,
that required schemas are loaded, and that namespaces are referenced correctly.
然而这确实有效:
var s = (from ss in context.testdata
orderby ss.id
select ss).ToList();
var c = s.Count();
我再次获得所有5136项。
我从这里得到了代码:
http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx
在这里:
http://www.timdavis.com.au/code/jquery-grid-with-asp-net-mvc/
知道我做错了吗?
答案 0 :(得分:0)
好的,在这里找到解决方案:
Strange Exception thrown using Dynamic Linq Entity Framework Query
这有效:
var s = context.testdata.OrderBy("it.id asc");