SingleOrDefault problem RRS feed

  • Question

  • I want to test if there is any data in my "query"


    If do a query where the customerid doesn't exist and the customerid is the primary key:

    dim c = (from t in ctx.customers where customerid = 1).SingleOrDefault


    I get a 404 error rather than it returning nothing


    If I do a similar query

    Dim qry as New URI(strDSPath & "Customers?filter=CustomerID%20eq%201")

    Dim obj as Customer = ctx.Execute(Of Customer)(qry).SingleOrDefault

    My obj is nothing which is what I want. It seems to be a problem when I do where clauses on the primary key.

    Monday, December 8, 2008 2:23 PM


  • When you do the first query, you are looking for a specific resource - so the Astoria server returns a 404 error (Resource not found).


    In the seconf query you are asking for the set of customers satisfying the predicate.  This returns an empty sequence and SingleOrDefault works as expected.


    We know this is akward and are thinking of adding a property in vNext so the client can ignore 404 errors.


    Thanks -



    Monday, December 8, 2008 5:04 PM