Wednesday, 8 July 2009

Resource not found for the segment 'xxxx'

I've received a "Resource not found for segment 'xxxx'" whilst using Azure.

This error appears to be triggered in the where clause when I am looking by primary key. I have found some resources that say it will throw an error when looking for a primary key that doesn't exist, rather than null.

The current solution is to wrap the query in an exception block:

try  
{  
  var person = from item in Connection.Persons
  where item.ID == id
  select item;  
  return person;
}  
catch( DataServiceQueryException ex )  
{  
  return null;
}  

No comments: