I'd like to configure a route that always returns a single entity.
The controller looks like:
class StatsController: ODataController {
public Stats Get() {
return new Stats();
}
}
The url to access it should be: GET ~/service-prefix/stats
All the options I've seen involve having to return IQueryable, or when returning a single entity, passing in a key in a form of ~/service-prefix/EntitySet(1)
Is there a way to achieve the above without having to return an IQueriable?
To access a single object without needing to have an entityset, odata v4 introduces the concept of singletons.
A singleton allows addressing a single entity directly from the entity container without having to know its key, and without requiring an entity set.
More info: