I find that the syntax used to incorporate system query options in an URL mainly falls into two categories.
1. Doesn't introduce a new segment. Examples include http://host/service/Products?$top=5
, and http://host/service.svc/Employees?$filter=Region eq @p1&@p1='WA'
.
2. Does introduce a new segment. For example, http://host/service/Cateoriges?$orderby=Products/$count
. Please mind the segment delimiter /
before $count
.
I'm wondering whether there is a simple rule that governs which syntax to use. Such a rule, it exists at all, could help provide insights, strengthen the understanding, and determine the correct syntax to use.
The rules are spelled out in the grammar for OData URIs. I wouldn't call them simple.
Consider using a client-side library that abstracts away the need to know anything about OData URI syntax.