none
Return complex types RRS feed

  • Question

  • I am using WF 4.3 (code first) and WCF Data services.

    I am trying to return a complex type from the WebGEt method

    I have registered the complex type class with the EF model as below in the model class

    modelBuilder.ComplexType<TextComplex>();

    I can see the TextComplex type in the Service Reference and If i test the WCF Service as standalone I see the return of the TextComplex in the browser. When i try to use it a client appliation I get an error that

    The property 'element' does not exist on type 'TextComplex'. Make sure to only use property names that are defined by the type.

    the code I am usiung to execute is: The test method is called "GetNothing"

    var test = ctx.Execute<TextComplex>(new Uri("GetNothing", UriKind.Relative));

    my text complex class is:

        public class TextComplex
        {
            public string user { get; set; }
            public string email { get; set; }
        }

    If I look at the metadata of the service I can see the method:

    <FunctionImport Name="GetNothing" m:HttpMethod="GET" ReturnType="Collection(FeedTrack.Data.TextComplex)"/>

    Any ideas how to get the complex type in the client side.

    Jawahar

    Wednesday, June 27, 2012 8:45 PM

Answers

  • ODataLib is a separate library that can serialize and deserialize ODataPayloads. Under the covers the 5.0 version of System.Data.Services.Client uses this component to serialize and deserialize requests and responses.

    To further elaborate on what Vitek is suggesting, he is indicating that you can use ODataLib itself (avail through NUGet http://nuget.org/packages/Microsoft.Data.OData/5.0.0.50403) to parse the values and get objects in this scenario.

    Thanks,

    Chris Robinson - SDET OData Team


    This posting is provided "AS IS" with no warranties, and confers no rights.

    Friday, June 29, 2012 5:20 PM
    Moderator

All replies

  • If possible, please upload the project to skydrive and post the link here.
    Friday, June 29, 2012 9:16 AM
  • If you need to return a collection of complex values then this is currently not supported by the client. Single complex value is (through a somewhat of a hack). You could use ODataLib to read the response directly which should work.

    Vitek Karas [MSFT]

    Friday, June 29, 2012 1:49 PM
    Moderator
  • The OataLib - is this somehting I can access on the Client side? ODataLib is part of the query Response returned after calling an Execute method on an Entity?

    Jawahar

    Friday, June 29, 2012 4:13 PM
  • ODataLib is a separate library that can serialize and deserialize ODataPayloads. Under the covers the 5.0 version of System.Data.Services.Client uses this component to serialize and deserialize requests and responses.

    To further elaborate on what Vitek is suggesting, he is indicating that you can use ODataLib itself (avail through NUGet http://nuget.org/packages/Microsoft.Data.OData/5.0.0.50403) to parse the values and get objects in this scenario.

    Thanks,

    Chris Robinson - SDET OData Team


    This posting is provided "AS IS" with no warranties, and confers no rights.

    Friday, June 29, 2012 5:20 PM
    Moderator