How can I get the WCF DS Client to not fail reading the results of a service operation that returns the type generated by a stored procedure call? RRS feed

  • Question

  • The short of it:

    Is there a way to materialize service operations that use Entity Framework, but do a stored procedure call instead of Linq to Entities?

    The details:

    I have an OData (WCF Data Service) that has several service operations in it. They all work fine.

    Today I tried to add a new service operation and I cannot get it to work in LinqPad.

    My new service operation is different from the others in that it calls a stored procedure (rather than using Linq To Entities).

    It looks like this:

    public IQueryable<MySproc_Result> GetTheDataINeed(long id)
        return CurrentDataSource.MySproc(id).AsQueryable();

    When I run this in LinqPad like this:

    CreateQuery<MySproc_Result>"GetTheDataINeed").AddQueryOption("id", "91675L")

    I get the following error:

    Cannot materialize a collection of a primitives or complex without the type 'LINQPad.User.MySproc_Result' being a collection.

    Note: I ran one of my other service operations using this syntax and it worked fine

    I decided to see if it would run in a browser (as a url). I plugged both this and a working service operation into Internet Explorer.

    The difference was easy to see right away:


    <?xml version="1.0" encoding="UTF-8"?>
    <GetTheDataINeed xmlns:m="namespace removed for brevity">
         <element m:type="MyModel.MySproc_Result">
            <SomeData>Data Goes Here</SomeData>
            <OtherData>Other Data Goes Here</OtherData>


    <?xml version="1.0" encoding="utf-8" ?> 
     <feed xml:base="http://localhost:26257/MyServiceHere.svc/" Other xmlns ommited>
      <title type="text">ValidServiceOperation</title> 
      <link rel="self" title="ValidServiceOperation" href="ValidServiceOperation" /> 
            <category ... ommited /> 
            <link lots of links ommited /> 
            <title /> 
                <name /> 
            <content type="application/xml">
                    <d:SomeData m:type="Edm.Int64">Some Data Here</d:SomeData> 
                    <d:OtherData m:type="Edm.DateTime">Other Data Here</d:OtherData>

    The working one seems to have quite a bit of meta data that the non-working one is missing. I am guessing that is why the materializer failed. What I don't know is how to get my service operation that is calling a stored procedure to get that xml format.

    Is there a way to materialize service operations that use Entity Framework, but do a stored procedure call?


    • I am running WCF Data Services 5.5.0 on both the server and the client and have install the 5.3.0 tooling.
    • I have tried running in a console app (to be sure that it is not just linqpad)
    • I have tried the following syntax as well, and it does not work:

      Execute<MySproc_Result>(new Uri("GetTheDataINeed?id=91675L", UriKind.Relative),
                              "GET" , false)
    Wednesday, July 3, 2013 10:05 PM

All replies

  • Hi Vaccanoll,

    Thanks for posting in MSDN forums. I'll try to involve some other senior engineers in this thread. It will take some time to get the response. Your patience will be appreciated.

    Thanks for your understanding and have a nice day!

    Best regards,

    Chester Hong
    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

    Friday, July 5, 2013 10:02 AM