internal static IQueryable Deserialize(IQueryable query, IEnumerable <ServiceQueryPart> queryParts, QueryResolver queryResolver)
        {
            if (query == null)
            {
                throw Error.ArgumentNull("query");
            }

            if (queryParts == null)
            {
                throw Error.ArgumentNull("queryParts");
            }

            foreach (ServiceQueryPart part in queryParts)
            {
                switch (part.QueryOperator)
                {
                case "filter":
                    try
                    {
                        query = DynamicQueryable.Where(query, part.Expression, queryResolver);
                    }
                    catch (ParseException e)
                    {
                        throw new ParseException(
                                  Error.Format(SRResources.ParseErrorInClause, "$filter", e.Message));
                    }
                    break;

                case "orderby":
                    try
                    {
                        query = DynamicQueryable.OrderBy(query, part.Expression, queryResolver);
                    }
                    catch (ParseException e)
                    {
                        throw new ParseException(
                                  Error.Format(SRResources.ParseErrorInClause, "$orderby", e.Message));
                    }
                    break;

                case "skip":
                    try
                    {
                        int skipCount = Convert.ToInt32(part.Expression, System.Globalization.CultureInfo.InvariantCulture);
                        if (skipCount < 0)
                        {
                            throw new ParseException(
                                      Error.Format(SRResources.PositiveIntegerExpectedForODataQueryParameter, "$skip", part.Expression));
                        }

                        query = DynamicQueryable.Skip(query, skipCount);
                    }
                    catch (FormatException e)
                    {
                        throw new ParseException(
                                  Error.Format(SRResources.ParseErrorInClause, "$skip", e.Message));
                    }
                    break;

                case "top":
                    try
                    {
                        int topCount = Convert.ToInt32(part.Expression, System.Globalization.CultureInfo.InvariantCulture);
                        if (topCount < 0)
                        {
                            throw new ParseException(
                                      Error.Format(SRResources.PositiveIntegerExpectedForODataQueryParameter, "$top", part.Expression));
                        }

                        query = DynamicQueryable.Take(query, topCount);
                    }
                    catch (FormatException e)
                    {
                        throw new ParseException(
                                  Error.Format(SRResources.ParseErrorInClause, "$top", e.Message));
                    }
                    break;
                }
            }

            return(query);
        }
 public IQueryable Skip(IQueryable source, int count)
 {
     return(DynamicQueryable.Skip(source, count));
 }