WCF Data Services fail to respond a query including orderby
I have a database view which I publish to other systems using WCF data services. The middle layer between the database and the WCF Data Services is built upon Entity Framework 4.1
When I query the view using a simple query without orderby, I get all results. If I include the orderby operator, the query fails with following error message (UseVerboseErrors is set to true): &l开发者_Python百科t;?xml version="1.0" encoding="utf-8" standalone="yes" ?>
- <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code />
<message xml:lang="de-DE">An error occurred while processing this request.</message>
- <innererror>
<message>Object reference not set to an instance of an object.</message>
<type>System.NullReferenceException</type>
<stacktrace>at lambda_method(Closure , StatesView ) at System.Linq.EnumerableSorter`2.ComputeKeys(TElement[] elements, Int32 count) at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count) at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext() at System.Linq.Enumerable.<TakeIterator>d__3a`1.MoveNext() at System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService) at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description) at System.Data.Services.DataService`1.HandleRequest()</stacktrace>
</innererror>
</error>
What do I do wrong? The view has a data service key defined on a column different to this one I want to use for sorting.
Here the query:http://localhost:6000/MyView?$orderby=number desc
As noted in the comments above the enumeration returned by an entity set query root (the property which returns the IQueryable) must not contain null items in it. If it does lot of things will go wrong, one of them being shown in the question above.
精彩评论