Answered $expand is broken in RTM?

  • Donnerstag, 12. April 2012 09:08
     
      Enthält Code

    Hi there,

    I'm getting following exception after installing WCF Data Services 5 RTM.

    <innererror> <message>Value cannot be null. Parameter name: value</message> <type>System.ArgumentNullException</type> <stacktrace>
    at System.Data.Services.WebUtil.CheckArgumentNull[T](T value, String parameterName)
    at System.Data.Services.Internal.ExpandedWrapper`1.set_ReferenceDescription(String value)
    at lambda_method(Closure , Shaper )
    at System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)
    at System.Data.Common.Internal.Materialization.Shaper`1.RowNestedResultEnumerator.MoveNext()
    at System.Data.Common.Internal.Materialization.Shaper`1.ObjectQueryNestedEnumerator.TryReadToNextElement()
    at System.Data.Common.Internal.Materialization.Shaper`1.ObjectQueryNestedEnumerator.MoveNext()
    at System.Data.Services.Providers.BasicExpandProvider.ExpandedEnumerator`1.MoveNext()
    at System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService, IODataResponseMessage responseMessage)
    at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description)
    at System.Data.Services.DataService`1.HandleRequest()
    </stacktrace> </innererror>

    October CTP worked just fine on the following query:

    https://localhost/nitro/api/data/Indexes?$expand=Children

    where Children is many-to-many relation.

Alle Antworten

  • Donnerstag, 12. April 2012 14:45
    Moderator
     
     

    Hi Lex,

    Thanks for moving this over from the blog.

    Can you provide a bit more information about your service?

    1) Are you using a 'plain' Entity-Framework model with a data-service on top? Or do you have a custom provider that just happens to use EF?

    2) What does the model for these two types actually look like?

    If possible, sharing a full repro might be the fastest way to get this resolved. If you're not comfortable posting it here, please consider emailing it to me at 'mmeehan' at msft.


    Matt Meehan (WCF Data Services / OData)

  • Donnerstag, 12. April 2012 16:16
    Moderator
     
     

    Also, are you using the DevArt Oracle provider for EF? There is a very similar exception message described in this thread:

    http://social.msdn.microsoft.com/Forums/pl-PL/adodotnetdataservices/thread/d3eeac7c-83df-4e98-900e-892de39c748b


    Matt Meehan (WCF Data Services / OData)

  • Donnerstag, 12. April 2012 16:58
     
      Enthält Code

    1) Yes, I use DevArt Oracle Provider.

    2) It is plain EF model, derived from ObjectContext (I've tried also DbContext approach, but it fails with the same exception).

    3) Here is snippet from Index entity:

    <EntityType Name="Index">
            <Key>
              <PropertyRef Name="Id" />
            </Key>
            <Property Name="Id" Type="Edm.String" Nullable="false" MaxLength="22" />
            <Property Name="Xid" Type="Edm.String" Nullable="false" MaxLength="22"  />
            <Property Name="Ts" Type="Edm.DateTime" Nullable="false" ConcurrencyMode="Fixed" p7:StoreGeneratedPattern="Computed" xmlns:p7="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
            <Property Name="Name" Type="Edm.String" Nullable="false" MaxLength="250" Unicode="true"  />
            <Property Name="Description" Type="Edm.String" Unicode="true"  />
            <Property Name="IssuerId" Type="Edm.String" MaxLength="22"  />
            <Property Name="Flags" Type="Edm.String" MaxLength="500" Unicode="true"  />
            <Property Name="Type" Type="Edm.Int32" DefaultValue="0" Nullable="false"  />
            <Property Name="ExtId" Type="Edm.String" MaxLength="100" Unicode="true"  />
            <Property Name="HInfo" Type="Nitro.Entities.HistoryInfo" Nullable="false"  />
            <NavigationProperty Name="Children" Relationship="Nitro.Entities.IndexTree" ToRole="Children" FromRole="Parents"  />
            <NavigationProperty Name="Parents" Relationship="Nitro.Entities.IndexTree" ToRole="Parents" FromRole="Children"  />
          </EntityType>

    Here is a snippet of the IndexTree relation:

          <Association Name="IndexTree">
            <End Type="Nitro.Entities.Index" Role="Parents" Multiplicity="*" />
            <End Type="Nitro.Entities.Index" Role="Children" Multiplicity="*" />
          </Association>
    

    Hope this helps,

    Lex

  • Donnerstag, 12. April 2012 20:44
    Moderator
     
     

    Thanks Lex,

    I've found some other very similar reports that are all tied to the DevArt provider, though your's is the first to mention $expand.

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/d3eeac7c-83df-4e98-900e-892de39c748b
    http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/111a400b-9904-4808-a5fb-e8f24c6fe037
    http://www.devart.com/forums/viewtopic.php?t=19762&sid=11131ba4e5cef255eda7f85cda36d6cf

    I am trying to establish what changed between the CTP and 5.0 which may have caused this. Do you know if it worked prior to that CTP? If possible could you try 4.0 RTM?


    Matt Meehan (WCF Data Services / OData)

  • Freitag, 13. April 2012 08:15
     
     

    Just downgraded to WCF Data Sevices 4 (plain .NET FX 4.0 libraries), had to disable all server paging.

    However, $expand options are working fine.

    ExpandedWrapper<T> in CTP had no property ReferenceDescription. Must be something new in RTM.

    Hope this helps,

    Lex

  • Freitag, 13. April 2012 18:05
    Moderator
     
     Beantwortet

    Hi again Lex,

    Thanks for trying that, I don't have a full repro (due to not having an Oracle instance or the DevArt provider), but I have a pretty clear picture of what is happening.

    Here is the expression tree that we build for a simple $expand query on 5.0 (pardon the terrible property names):

    value(System.Data.Objects.ObjectQuery`1[DataServicesRepros.Web.Thing1])

    .MergeAs(NoTracking)

    .Select(p => new ExpandedWrapper`2() {ExpandedElement = p, Description = "Things", ReferenceDescription = "", ProjectedProperty0 = p.Things})

    Notice the value of the property is an empty-string constant because no refrence properties were expanded. My working assumption is that something in the DevArt provider collapses this to null somehow.

    As for a fix, I can't promise anything for a specific release timeline, but the team is committed to releasing an implementation of the new 'efficient json' format ASAP, and a fix for this will be released then at the latest.

    Also, can you elaborate about what is happening with server-driven paging? We have relatively little data on the DevArt provider.


    Matt Meehan (WCF Data Services / OData)

  • Sonntag, 15. April 2012 18:46
     
     

    Hi I have faces this issue with DeVart , I may case i was using a large query in <DefiningQuery> tag and devart was not able to resolve parameter for some queries especially the queries that was using more that two parameters. I would suggest to check out Devart forum too. 

  • Mittwoch, 18. April 2012 16:58
     
     
    Please refer to http://blogs.planetsoftware.com.au/paul/archive/2011/01/28/ef4-part-9-tweaks-to-deal-with-oracle-and-wcf.aspx . This is actually the problem of WCF Data Services which doesn't take into account the peculiarities of other RDMS (Oracle treats empty strings in varchar columns as null).

    Devart Team
    http://www.devart.com/dotconnect
    ADO.NET data providers for Oracle, MySQL, PostgreSQL, SQLite with Entity Framework and LINQ to SQL support

  • Montag, 23. April 2012 14:27
     
     

    Oracle treats empty strings as nulls, it's true. But this query doesn't request empty string from server.

    "Treats empty strings as nulls" is irrelevant in this case, because you don't roundtrip constants to RDBMS back and forth just for the sake of entity materialization. However, if you do, this is definitely a bug.


  • Montag, 23. April 2012 18:33
     
     

    Hi Lex - we posted some prerelease bits that we believe will fix this issue - if you get an opportunity, would you download them, try them out and provide some feedback on whether the fix worked in your environment?

    http://blogs.msdn.com/b/astoriateam/archive/2012/04/20/wcf-data-services-5-1-0-rc-prerelease.aspx

    Thanks,
    Mark


    HTH, Mark Stafford

  • Mittwoch, 25. April 2012 13:23
     
     

    Ok. I'll give it a try.

    Thank you for the fast support

  • Donnerstag, 3. Mai 2012 11:45
     
     

    It also occurs with WCF Data Service 5.0 using the Oracle ODP.net provider (as well as the Oracle DevArt provider).

    I'm glad to say that I have tested 5.1.0 rc on the Oracle ODP.net provider, and it seems to have fixed this 5.0 specific $expand defect!

    BTW. Now we just have two open issues using DS 5.1 with Oracle ODP.net 11.2.0.3:

    select limited to 8 columns
    Minimizing OUTER/CROSS APPLY problems


    • Bearbeitet Arieh2 Donnerstag, 3. Mai 2012 12:42
    •  
  • Freitag, 4. Mai 2012 11:13
     
     
    I second this. 5.1.0-pre works fine.