Question

I have a service operation of the form:

[WebGet]
public IQueryable<BusinessObject> BusinessObjectsByType(string name)

with access rule

config.SetServiceOperationAccessRule("BusinessObjectsByType", ServiceOperationRights.All);

When I access this service operation through a web browser, it exposes the data but not in feeds and entries (AtomPub format) and neither does it let me use basic query options like $top, $orderby, etc complaining that these 'cannot be applied to the requested resource'. I have matched all requirements specified at http://msdn.microsoft.com/en-us/library/cc668788.aspx but to no success. Any help will be appreciated. Thanks.

Was it helpful?

Solution

If the BussinesObject is not recognized as entity, the service operation will be treated as if returning IEnumerable instead. For the querying to work the service operation must return IQueryable where T is an entity type. Assuming either EF or Reflection provider an entity type is a type which has a key property (either by heuristic or through DataServiceKey attribute) and for which there's a property on the context class of type IQueryable. If the BussinesObject is not an entity, WCF Data Services can't support queries on the result of the service operation. There are many reasons, to name just one: in order to serialize the response each object must have a unique URL (it's atom:id), to be able to generate a unique URL the object must have key properties. And key properties can only be defined on entities.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top