Dynamic Linq/ Dynamic Query: cannot get data for jqGrid

asp.net-mvc dynamic-linq entity-framework jqgrid linq

Question

I'm using jqGrid and I have a problem getting Dynamic Linq to work. I used NuGet to install Dynamic and added "using System.Linq.Dynamic;".

Using VS 2010 Pro, MVC 3.0

This works:

var s = context.testdata;
var c = s.Count();

c shows 5136 items.

But I cannot get the dynamic approach to work:

var s = context.testdata.OrderBy("id asc");

I get this error message:

'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.

This however does work:

var s = (from ss in context.testdata
                      orderby ss.id
                      select ss).ToList();
var c = s.Count();

Again I get all 5136 items.

I've got the code from here: http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx
and here:
http://www.timdavis.com.au/code/jquery-grid-with-asp-net-mvc/

Any idea what I am doing wrong?

1
0
6/20/2012 7:20:33 AM

Accepted Answer

OK, found the solution here:
Strange Exception thrown using Dynamic Linq Entity Framework Query

This works:

var s = context.testdata.OrderBy("it.id asc");
0
5/23/2017 10:34:26 AM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow