locked
OData Provider with WCF 4.0: Paging Operations with null parameters RRS feed

  • Question

  • Hi,

    I'm trying to get odata server side paging to work for an operation with nullable parameters, so something like this:

    The metadata for the operation is defined from a method like this one:

    public IEnumerable<ResultType> GetDataFromDates(DateTime startDate, DateTime? endDate)
    {
    // Do something
    }


    the call is like this, the endDate is null:

    /MyService.svc/GetDataFromDates?startDate=datetime'2013-01-01'


    Then, depending on which machine i'm running on, i get one of the following two skiptokens:

    Either

     <link rel="next">
        <m:error>
          <m:code></m:code>
          <m:message xml:lang="de-CH">An error occurred while processing this request.</m:message>
          <m:innererror>
            <m:message>Object reference not set to an instance of an object.</m:message>
            <m:type>System.NullReferenceException</m:type>
            <m:stacktrace>   at System.Data.Services.Serializers.DataStringEscapeBuilder.Build()&#xD;
       at System.Data.Services.Serializers.Serializer.GetNextPageQueryParametersForRootContainer()&#xD;
       at System.Data.Services.Serializers.Serializer.GetNextLinkUri(Object lastObject, IExpandedResult skipTokenExpandedResult, Uri absoluteUri)&#xD;
       at System.Data.Services.Serializers.SyndicationSerializer.WriteNextPageLink(Object lastElement, IExpandedResult expandedResult, Uri absoluteUri)&#xD;
       at System.Data.Services.Serializers.SyndicationSerializer.&lt;DeferredFeedItems&gt;d__b.MoveNext()&#xD;
       at System.ServiceModel.Syndication.Atom10FeedFormatter.WriteItems(XmlWriter writer, IEnumerable`1 items, Uri feedBaseUri)&#xD;
       at System.ServiceModel.Syndication.Atom10FeedFormatter.WriteFeedTo(XmlWriter writer, SyndicationFeed feed, Boolean isSourceFeed)&#xD;
       at System.ServiceModel.Syndication.Atom10FeedFormatter.WriteTo(XmlWriter writer)&#xD;
       at System.Data.Services.Serializers.Serializer.WriteRequest(IEnumerator queryResults, Boolean hasMoved)&#xD;
       at System.Data.Services.ResponseBodyWriter.Write(Stream stream)</m:stacktrace>
          </m:innererror>
        </m:error>


    , and the closing tags for the xml documents are missing, or

    <link rel="next" href="/MyService.svc/GetDataFromDates?startDate=datetime'2013-01-01'&amp;endDate=&amp;$skiptoken='mytoken' />
    . Also the second one is faulty, as the request with an empty parameter value is not valid in odata.

    Judging on the Symbol server debugger, it seems to depend on the implementation of

    System.Data.Services.Serializers.Serializer.GetNextPageQueryParametersForRootContainer(),

    but both machines that i have tested on are using the same version of system.Data.Services.

    Does anyone know what could be the issue here?




    • Edited by Gabriel Katz Monday, March 4, 2013 1:42 PM Small mistakes
    Monday, March 4, 2013 1:40 PM

Answers

  • I just hit that bug too.  As a workaround I found that you should specify all the keys, and leave the values empty.  This works around the NullReferenceException.

    This way:

    /MyService.svc/GetDataFromDates?startDate=datetime'2013-01-01'&endDate=

    Ideally of course the library should handle properly missing parameters.

    Thursday, March 7, 2013 12:30 AM

All replies

  • Hi Gabriel,

    Welcome to the MSDN forum.

    I am trying to involve a senior expert into your thread. Please wait for the response. Sorry for any inconvenience.

    Good day.


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 6, 2013 7:25 AM
  • I just hit that bug too.  As a workaround I found that you should specify all the keys, and leave the values empty.  This works around the NullReferenceException.

    This way:

    /MyService.svc/GetDataFromDates?startDate=datetime'2013-01-01'&endDate=

    Ideally of course the library should handle properly missing parameters.

    Thursday, March 7, 2013 12:30 AM