locked
System.Data.Services.Client "The method 'First' is not supported." RRS feed

  • Question

  • I am using ADO.NET Data Services to return a set of customers from an Entity Framework Model.  Now when I try to use operations like "First", "Single", "Count" I get error messages saying

    "The method 'First' is not supported."

    Is this a known issue?  I am not using SilverLight.
    Saturday, September 26, 2009 10:25 AM

Answers

  • The overload of First taking a predicate is currently not supported.  try:

    _stkDbEntity.StockSet.Where(stk => stk.Id == stockId).First()

    • Marked as answer by Arjuna_M Monday, September 28, 2009 4:45 AM
    Monday, September 28, 2009 4:40 AM
    Moderator

All replies

  • Hi,

    Are you doing this on the client  or the service (via current data source)? Is there projection involved? An example would help, can you show us the query which you call .First on?

    Regards,
    PQ
    Peter Q. http://blogs.msdn.com/peter_qian
    Sunday, September 27, 2009 10:12 AM
    Answerer
  • Hi Peter,

    I am doing this on the client.  What I do is

    1. Add a service reference to the service (.svc) from the client side.
    2. Call first in the following manner

    _stkDbEntity.StockSet.First(stk => stk.Id == stockId)

    _stkDbEntity is an instance of System.Data.Services.Client.DataServiceContext

    Thanks
    Arjuna.
    Sunday, September 27, 2009 10:45 AM
  • Hi Arjuna,
      Where are you running this application ?
      Inside a Console application/windows application/Silverlight application ?
    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Sunday, September 27, 2009 9:13 PM
    Moderator
  • Hi Phani,

    I am running this inside a Web Application (not a Silverlight).

    Thanks
    Arjuna.
    Monday, September 28, 2009 2:55 AM
  • The overload of First taking a predicate is currently not supported.  try:

    _stkDbEntity.StockSet.Where(stk => stk.Id == stockId).First()

    • Marked as answer by Arjuna_M Monday, September 28, 2009 4:45 AM
    Monday, September 28, 2009 4:40 AM
    Moderator
  • Hi Andrew,

    Thanks it works, but why does not First take a predicate.  If this is the case then what are the other methods that I should be aware of?

    Thanks
    Arjuna.
    Monday, September 28, 2009 4:45 AM
  • It was a scoping decision based on the fact the query could be rewritten.

    The ADO.NET Data Services client only supports LINQ methods and expressions that can be translated to URIs.  that is the general limitation.

    Monday, September 28, 2009 8:15 PM
    Moderator