Using Dynamic Linq Entity Framework Query, an unusual exception was thrown.

dynamic-linq entity-framework linq

Question

I have a gallery entity framework class,and I'm attempting to use the Dynamic Linq Library posted on ScottGu's blog to query the entity set. The failing line of code reads:

return context.Galleries.OrderBy(sidx + " " + sord).Skip(page * rows).Take(rows).ToList();

sidx=="Name", and sord=="desc".

The Gallery object does have a property called "Name". However, when executed, i get the following exception:

'Title' 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., near simple identifier, line 6, column 1.

Does anyone know what this means?

1
3
3/6/2014 9:05:47 PM

Accepted Answer

I found a fix, but it doesnt explain the original issue. The query was in a library, and being referenced from the asp.net mvc application. It compiled fine, but bombed at runtime. The fix was putting the dynamiclinq class in the mvc app itself, returning a plain IQueryable form the library, and doing the filtering in the controller itself. The exact same code worked there. Somehow the separation in the library caused the issue.

0
7/28/2009 1:43:19 AM

Popular Answer

"it" alias was the problem so the following code should works:

prefix your filter field name Title as it.Title

I found the answer here .. http://challenge-me.ws/?tag=/Exceptions



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