Odata expand seems to have a problem RRS feed

  • Question

  • Hi,

    I got a very strange Problem with an odata Service,

    When I put the following Request to my service, the result is OK

    http://localhost:53733/WcfDataService1.svc/artikel?$filter=a_nr eq '0101030' & $expand=artgruppe,artinhalt/inhaltstoff

    datamodel description

    artikel has one artgruppe, and several artinhalt

    one artinhalt references one inhaltstoff

    when I query in the way above, I get a correct result.

    when I query

    http://localhost:53733/WcfDataService1.svc/artikel?$filter=a_nr eq '0101030' & $expand=artinhalt/inhaltstoff

    I get a Syntax Error From Odata which cannot be really the expected result :

    <code />
    ="de-DE">Fehler beim Verarbeiten
    dieser Anforderung.
    - <innererror>
    <message>Fehler beim Ausführen der Befehlsdefinition. Weitere Informationen
    finden Sie in der internen Ausnahme.
    entityCommand, CommandBehavior behavior) bei
    context, ObjectParameterCollection parameterValues) bei
    System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) bei
    bei System.Data.Services.WebUtil.GetRequestEnumerator(IEnumerable enumerable)
    bei System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription
    description, IDataService dataService, IODataResponseMessage responseMessage)
    bei System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription
    description) bei System.Data.Services.DataService`1.HandleRequest()
    - <internalexception>
    <message>ERROR [42000] [IBM][IDS/UNIX32] A syntax error has
    <stacktrace>bei IBM.Data.DB2.DB2Command.ExecuteReaderObject(CommandBehavior
    behavior, String method, DB2CursorType reqCursorType, Boolean
    abortOnOptValueChg, Boolean skipDeleted, Boolean isResultSet, Int32 maxRows,
    Boolean skipInitialValidation) bei
    IBM.Data.DB2.DB2Command.ExecuteReaderObject(CommandBehavior behavior, String
    method) bei IBM.Data.DB2.DB2Command.ExecuteReader(CommandBehavior behavior) bei
    IBM.Data.DB2.DB2Command.ExecuteDbDataReader(CommandBehavior behavior) bei
    System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) bei
    entityCommand, CommandBehavior behavior)


    unfortunately I don ´t know what is generated because the profiler just traces only syntactical correct queries ...

    In my opinion this is a bug , I already tried to submit this in connect with a less detailed explanation but got no comments until now.

    Thank you for any helpful information

    Thursday, December 20, 2012 11:10 AM

All replies

  • Could you provide a little more information:
    1) What version of WCF DS is the server?
    2) What's the MaxProtocolVersion of the server?

    I agree that the query looks fine.  Have you tried other similar combinations to see what happens? For instance, removing the filter clause simplifies things but should have no effect on the issue. So I would try that. Then, could you try other combinations of expand and see what works and what repro's this error.

    It looks to me like this error is coming up from DB2 through the ExpandProvider, and WCF DS is just surfacing the error. I assume that you have a custom provider to work with DB2? Do you own this code? It seems likely to me that the bug is in the custom provider.


    Thursday, December 20, 2012 6:21 PM
  • Hi Ian,

    thank you for the quick answer.

    The Provider I use is the official IBM .net provider for informix , which unfortunately is not open source. ( I have not tried to reassemble it with reflector)

    provider=IBM.Data.DB2;provider Version 10.1.4 date 2012/04/05

    As Database I have an Informix database.

    Here the config of the Service:

     config.SetEntitySetAccessRule("*"EntitySetRights.All | EntitySetRights.AllWrite);
                 config.UseVerboseErrors = true;
                config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;           


    Also in my opinion it may be possible that it is a driver problem. But because I do not know exactly which parts are provided by IBM and which by Microsoft, I first tried here.

    Is there a possibility of intercepting the generated queries ? To have a useful error report for IBM (if needed) this might be helpful

    Thank you

    Thursday, December 20, 2012 9:41 PM
  • Hi Slido,

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

    Merry Christmas!

    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.

    Monday, December 24, 2012 8:50 AM
  • Hi Alexander,

    thank you for the answer and for working on this problem. When using the Odata tools I also found another thing which might have to do something with the problem above . For this problem I also made a demo . I had put this on connect case 774744 to visual studio support but unfortunately they are not directly responsible any more for 2010 questions. ( In my opinion this would even happen with 2012 if the VS addins for Informix would be available ) . See a copy of the case :

    I am using Informix IBM.Data.DB2.Dll Version
    Microsoft Data.EDM
    Entity Framework

    In the Demo I Attached I found out that it seems to be a problem of the IBM Driver.
    when I call http://localhost:53732/WcfDemoService.svc/article?$top=10&$expand=preiseinheit
    ( article contains two lines, preiseinheit contains no lines)

    it crashes:

    - <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
      <code />
      <message xml:lang="de-DE">Fehler beim Verarbeiten dieser Anforderung.</message>
    - <innererror>
      <message>Die Eigenschaft 'pe_faktor' bei 'preiseinheit' konnte nicht auf einen 'null'-Wert festgelegt werden. Sie müssen diese Eigenschaft auf einen Nicht-NULL-Wert des Typs 'Decimal' festlegen.</message>
      <stacktrace>bei System.Data.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue(DbDataReader reader, Int32 ordinal) bei System.Data.Common.Internal.Materialization.Shaper.GetPropertyValueWithErrorHandling[TProperty](Int32 ordinal, String propertyName, String typeName) bei lambda_method(Closure , Shaper ) bei System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper) bei System.Data.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext() bei System.Data.Services.Providers.BasicExpandProvider.ExpandedEnumerator`1.MoveNext() bei System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService, IODataResponseMessage responseMessage) bei System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description) bei System.Data.Services.DataService`1.HandleRequest()</stacktrace>

    when I call without top it crashes not  .
    See my attached demo project

    Merry Christmas

    • Edited by slido Tuesday, December 25, 2012 9:35 AM
    Tuesday, December 25, 2012 9:35 AM
  • Hello,

    The error is thrown by IBM. There are several posts on IBM site about related errors-


    This one also talks about similar issue-


    Please contact IBM support as the error is thrown by the IBM provider.

    -Sandeep Chalke.

    • Proposed as answer by SandeepChalke Monday, February 4, 2013 5:39 PM
    Wednesday, January 16, 2013 12:54 PM
  • Hello,

    thank you very much for the hint to the other thread.

    The entry from the developer works forum really seems to describe a similar problem.

    Meanwhile I found out that in my case the generated Query contains a

    CAST('' AS nvarchar(0)) AS C2

    which causes the systax error. ( casts to nvarchar  are not allowed to have a length of 0) At the moment this does not help me very much but maybe the people who wrote the query generation .

    instead it may have been ok to generate

    CAST('' AS nvarchar ) AS C2

    Thursday, January 17, 2013 9:56 AM