exception when using linq queries with QueryOperationResponse GetContinuation() RRS feed

  • Question

  • Hello,


    I am trying to use linq query to filter out the list of objects. However, I got into trouble when taking in consideration of the paging limit of the database by calling "GetContinuation()"

    System.InvalidCastException: Unable to cast object of type 'DataServiceOrderedQuery[JobApiService.Job]' to type 'System.Data.Services.Client.QueryOperationResponse'.


     List<Object> ReturnList = new List<Object>();
        IEnumerable<Object> query = (from j in _jent.Jobs where j.Closed == false || (j.Closed == true && j.UpdatedOn > shopLastRetrievalDate) select j).AsEnumerable();
        // IEnumerable<Object> query = _jent.Jobs.AddQueryOption("Closed", "False").Execute();
        ReturnList = query.ToList();
        DataServiceQueryContinuation continuation = ((QueryOperationResponse)query).GetContinuation();
        while (continuation != null)
         //query for the next partial set of users
         query = _jent.Execute<Object>(continuation.NextLinkUri);
         //Add the next set of users to the full list
         //get new continuation object
         continuation = ((QueryOperationResponse)query).GetContinuation();
        //Logger.LogInfo("Paged list size= " + pagedList.Count);
       catch (Exception exception)
        Logger.LogError(EVT_SRC, exception.ToString());
       return ReturnList.ConvertAll(ObjectToApiServiceItem<JobApiService.Job>); ;

    What would be the best way to use linq queries and with GetContinuation() ?


    Thursday, July 21, 2011 7:48 PM


All replies