Print Page | Close Window

How to create paged data collection using devforce EntityManager ?

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1902
Printed Date: 21-Apr-2026 at 3:49pm


Topic: How to create paged data collection using devforce EntityManager ?
Posted By: ehsan
Subject: How to create paged data collection using devforce EntityManager ?
Date Posted: 21-Jun-2010 at 4:51am

I want to use this query to create a paged datasource for a datapager :

IEntityQuery<testTable> query = (from r in mgr.testTables select r).Skip(this.pageSize * this.pageIndex).Take(this.pageSize);

query.ExecuteAsync(

args =>

{

IEnumerator e = args.Results.GetEnumerator();

}

);
 
but I get this exception when "args.Results.GetEnumerator()" executes :
 
An exception occurred during the operation, making the result invalid.  Check InnerException for exception details.
 
It executes OK when I remove Skip & Take sections . Any idea(blade!) ?



Replies:
Posted By: GregD
Date Posted: 21-Jun-2010 at 5:20pm
What does the InnerException say?


Posted By: ehsan
Date Posted: 21-Jun-2010 at 8:56pm
{EntityServerException: The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'. ---> System.NotSupportedException: The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.
   at IdeaBlade.EntityModel.Server.EntityServerQueryInterceptor.HandleException(Exception e, PersistenceFailure failureType)
   at IdeaBlade.EntityModel.Server.EntityServerQueryInterceptor.OnExecuteQuery()
   at IdeaBlade.EntityModel.Server.EntityServerQueryInterceptor.Execute(IEntityQuery entityQuery, SessionBundle sessionBundle, EntityServer entityServer)
   at IdeaBlade.EntityModel.Server.EntityServer.Fetch(SessionBundle sessionBundle, IEntityQuerySurrogate surrogate)
   at SyncInvokeFetch(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
   at IdeaBlade.EntityModel.EntityManager.HandleEntityServerException(Exception pException, Boolean pTryToHandle, PersistenceOperation pOperation)
   at IdeaBlade.EntityModel.EntityManager.<ExecuteQueryAsyncCore>b__4e[T](EntityQueryOperation`1 op)
   at IdeaBlade.EntityModel.AsyncProcessor`1.<Execute>b__5(Object x)}
 
Oh, I understood the problem ! It's so simple I just dont know why I didn't care this message before posting this topic !!!
I must use OrderBy section before using skip :
 

IEntityQuery<testTable> query = (from r in mgr.testTables select r).OrderBy(r => r.id).Skip(this.pageSize * this.pageIndex).Take(this.pageSize);




Print Page | Close Window