locked
Error translating Linq expression to URI: The method 'OfType' is not supported. RRS feed

  • Question

  • Hi all

    I am using march 2011 ctp2

    I am using the following query

    var q = from t in ctx.Tests.OfType<TestBig>() select t;

    And I get the error

    Error translating Linq expression to URI: The method 'OfType' is not supported.

    Many thanks

     

     

    Friday, April 1, 2011 1:01 PM

All replies

  • Hi,

    It seems that someone else is reporting this issue too at the pre-release forum, http://social.msdn.microsoft.com/Forums/en/dataservices/thread/7f3eca08-2cd7-4728-8584-0b2b478471ce.  I will move this thread to WCF Data Services (pre-release) forum for better support.

    Good day!

    Thanks


    Michael Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Monday, April 4, 2011 1:27 AM
  • Hi

    Thanks for the reply

    Couple of things

     

    1) I am using localhost how do I get fiddler to capture the query string ? ( if I try http://localhost.:2162/Service1.svc/ it produces an error as per http://www.west-wind.com/weblog/posts/596348.aspx )

     

    2) The code below, I think the final query produces invalid URL

          var ctx = new OurServiceReference.OurEntities(new Uri("http://localhost:2162/Service1.svc/"));

          var u = from t in ctx.Users select t;
          var xxx = u.Count();  // Works fine


          var xxxx = from t in ctx.Tests select t; // works fine
          xxx = xxxx.Count();

          var xx = from t in ctx.Tests.OfType<OurServiceReference.TestBig>() select t; // error I think it produces an invalid URL

     

    Wednesday, April 6, 2011 7:27 AM
  • Hi,

    1) To get fiddler working you can point your client to the fiddler proxy directly. So instead of http://localhost:2162 use http://ipv4.fiddler:2162. Specify this URL in your context creation and the GET requests will be sent there. Fiddler will trace it and forward it to the localhost.

    2) Could you please post the URL which you think is invalid? Just call ToString on the query.

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, April 6, 2011 11:24 AM
    Moderator
  • Hi

    Got the query

    var xx = from t in ctx.Tests.OfType<OurServiceReference.TestBig>() select t;

    http://localhost:2162/OurService.svc/Tests/OurModel.TestBig() // fails

    http://localhost:2162/OurService.svc/Tests/$count // works

    http://localhost:2162/OurService.svc/Users/$count    // works

     

     HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

    Thanks

    Paul

     



    • Edited by Watty45 Wednesday, April 6, 2011 1:39 PM add more info
    Wednesday, April 6, 2011 1:36 PM
  • Hi All

     

    Any update on this one I thought oftype was a new feature of this release.

     

    Many thanks

    Paul

    Wednesday, April 13, 2011 8:24 AM
  • Hi,

    I assume you're running this using Cassini (the default web server which VS uses to host services locally)...

    If that's so, then this is a known limitation. Cassini fails on these queries because of the dot in the last segment. It thinks it's a file and tries to find it in the file system (without asking the service to handle the URL instead).

    Workaround is to use either IIS Express or full IIS.

    Thanks,


    Vitek Karas [MSFT]
    Friday, April 15, 2011 4:49 PM
    Moderator