I am trying to use dynamic LINQ to Entity in my application to specify an OrderBy attribute at runtime. However, when using the code, as described in most documents:
var query = context.Customer.OrderBy("Name");
I got the following exception:
System.Data.EntitySqlException: "Name" cannot be resolved in the current scope or context. Ensure that all referenced variables are in an area that requires loading schemas, and that the namespaces are correctly specified.
After much searching, I found this MSDN page:
http://msdn.microsoft.com/en-us/library/bb358828.aspx
Which included the following code example:
ObjectQuery<Product> productQuery2 = productQuery1.OrderBy("it.ProductID");
This prompted me to change my code to the following:
var query = context.Customer.OrderBy("it.Name");
. - , OrderBy LINQ to Entity? , , , - ?
,