locked
Data service ignores $skip and $top parameters when entity ID has '#' symbol RRS feed

  • Question

  • Hello,

    Let say that one of entities in my service has ID like 'id#12'. URL escaped value of that ID is 'id%2312'

    When I tried to do following operation in my service http://localhost/service.svc/ContentTreeNodes('id%2312')/Children it works fine.

    But following version of request http://localhost/service.svc/ContentTreeNodes('id%2312')/Children?$skip=0&$top=5 does not work as expected: $skip and $top parameters are ignored.

    I know that '#' is not a very good symbol and so my service implemented workaround from this article http://blogs.msdn.com/b/peter_qian/archive/2010/05/25/using-wcf-data-service-with-restricted-characrters-as-keys.aspx.

    I even have done debugging my issue with debug symbols loaded for WCF Data Services libraries and found that both calls of ReadSkipOrTopArgument() returns false, but they work fine if entity ID does not contains '#' symbol.

    Here is piece of related code from RequestQueryProcessor.cs file:

            /// <summary>
            /// Finds out the appropriate value for skip and top parameters for the current request
            /// </summary>
            private void ObtainSkipTopCounts()
            {
                int count;
     
                if (this.ReadSkipOrTopArgument(XmlConstants.HttpQueryStringSkip, out count))
                {
                    this.skipCount = count;
                }
     
                int pageSize = 0;
                if (this.IsStandardPaged)
                {
                    pageSize = this.description.LastSegmentInfo.TargetContainer.PageSize;
                }
     
                if (this.ReadSkipOrTopArgument(XmlConstants.HttpQueryStringTop, out count))
                {
                    this.topCount = count;
                    if (this.IsStandardPaged && pageSize < this.topCount.Value)
                    {
                        // If $top is greater than or equal to page size, we will need a $skiptoken and
                        // thus our response will be 2.0
                        this.description.RaiseResponseVersion(2, 0);
                        this.topCount = pageSize;
                    }
                }
                else if (this.IsStandardPaged)
                {
                    // Paging forces response version of 2.0
                    this.description.RaiseResponseVersion(2, 0);
                    this.topCount = pageSize;
                }
     
                if (this.topCount != null || this.skipCount != null)
                {
                    this.CheckSetQueryApplicable();
                }
            }

    Unfortunately, debugger did not show me details that allow me to understand the problem.

    But I think that it looks like an issue inside Data services implementation.

    Wednesday, June 27, 2012 3:16 PM

All replies