OData 4.0 Spec Compliance
OhData targets the OData 4.0 specification. This page documents which sections are implemented and any known limitations.
Conformance posture
OhData has not been run against an official OASIS conformance test suite - the table below is our own honest self-assessment against the four conformance tiers the protocol describes, derived from the row-by-row detail further down this page. Treat it as a map of "what to expect", not a certification claim.
| Tier | Posture |
|---|---|
Minimal conformance (read entities and collections, $top/$skip/$orderby/$select/$count, error format, content-type negotiation) |
✅ Met |
Minimal-updatable (create/update/delete entities, $ref link management) |
✅ Met |
Intermediate conformance (functions/actions, $expand, $search, batch requests, deep insert) |
⚠️ Substantially met, with named exceptions: JSON batch requests are not supported (see Known Limitations below); @odata.bind (link an existing entity inline during insert) returns 501 Not Implemented rather than being honored; PATCH partial-merge on a complex property and raw /$value property writes are documented non-goals (see Individual property access below) |
| Advanced conformance (§13.1.3) | ⚠️ Not claimed as a level, but item 9 is substantially implemented - and conditionally, which is the part to read. Advanced item 9 (advanced $expand options) is met for 6 of 9: nested $filter (9.2), $orderby (9.4), $count (9.5), $top/$skip (9.6) and $levels (9.8), plus multi-level nesting. The condition: those are served by the EF Core pushdown, which requires the navigation to be delegate-less and the source to be an EF-backed IQueryable. On a delegate-backed navigation all of them are also applied - in memory rather than as SQL, with the semantic caveat that carries; see Delegate-backed navigations… under Declared deviations. Not implemented: references for expanded properties (9.1), a cast segment in $expand (9.3), $search on an expanded collection (9.7). The level itself is not claimed because of those three plus the non-$expand Advanced items. |
OData 4.01-only additions ($compute, aliases, cross joins) |
❌ Not targeted - $compute is unimplemented because the pinned Microsoft.AspNetCore.OData package range predates 4.01 support (see Known Limitations); no other 4.01-only feature is attempted |
JSON payload casing
Response property names are serialized in PascalCase by default — the same identifiers the EDM
declares in $metadata — so payload casing matches $metadata casing. This makes
OhData correct out of the box for case-sensitive OData-native clients (e.g. Microsoft.OData.Client).
The casing is OhData-owned (not inherited from the host's HttpJsonOptions); switch to camelCase with
AddOhData(o => o.WithJsonPropertyNamingPolicy(JsonNamingPolicy.CamelCase)). The OpenAPI/Swagger
companion packages generate schema property names under this same policy, so the documented casing
matches the wire. See
query-options.md → JSON property casing.
Protocol headers
| Feature | Section | Status | Notes |
|---|---|---|---|
OData-Version: 4.0 response header |
§8.1.5 | ✅ | Added to all responses, by the outermost group filter — so a response an inner filter short-circuits carries it too. |
OData-MaxVersion request header |
§8.2.7 | ✅ | Parsed as major.minor (whitespace-tolerant); 4.0 or higher (4.01, 5.0, ...) proceeds, a value below 4.0 or an unparseable value is rejected with 400 Bad Request (UnsupportedODataVersion). Enforced at the OData route-group level, so it applies to the service document, $metadata, and every entity-set/bound-operation route. Never echoed in responses (request-only header). |
Content-Type: application/json |
§8.1.1 | ✅ | All responses except GET /$metadata, which returns application/xml, and the two /$count segments, which return text/plain per §11.2.9 |
$format query option |
§11.2.10 | ✅ | json and application/json accepted; others → 400. Not on the /$count segments, where §11.2.9 disallows negotiation entirely, so any $format value is accepted and ignored — see the $count row below |
Accept header validation |
§8.2.1 | ✅ | Non-JSON accept headers → 406. Not on the /$count segments: §11.2.9 is the specific rule over Minimal item 5.1's general one, and Microsoft.AspNetCore.OData never negotiates there either — see the $count row below |
Request conditional headers
| Feature | Section | Status | Notes |
|---|---|---|---|
If-Match on every state-changing route |
§8.2.4 | ✅ | 412 on mismatch; * wildcard supported. If-Match (including *) against a resource that does not exist returns 412 Precondition Failed, not 404 — the existence check happens before the wildcard short-circuit, per RFC 7232 §3.1 / §11.4.1.1. The gate covers every state-changing route the framework owns and can key: entity PUT/PATCH/DELETE, both structural-property writes, all three $ref link-management routes (POST/PUT/DELETE /{Set}({key})/{Nav}/$ref) and the navigation-POST create route — the last four previously discarded a received If-Match and performed the write with a 204/201, a lost update on relationship state. The gate fires before the body is read and before the handler delegate runs, so a refused write provably mutates nothing; it is not atomic (see etags.md). Bound and unbound actions are excluded, and that is a known deviation rather than a spec allowance — see Known limitations below and #566 |
If-Match with multiple ETags |
§8.2.4 | ✅ | Comma-separated list per RFC 7232 §3.1 |
If-None-Match on GET → 304 |
§8.2.5 | ✅ | Returns 304 Not Modified when ETag matches |
If-None-Match (non-*) on a write → 412 |
§8.2.5 / RFC 9110 §13.1.2 | ✅ | A non-* If-None-Match that matches the current ETag makes the condition false, so the write returns 412. If-None-Match uses weak comparison, so W/"<current>" does match here — deliberately unlike If-Match, see the row below. When both headers are present, If-Match is evaluated first and wins outright, per RFC 9110 §13.2.2 |
If-None-Match: * on PUT (create-guard) |
§11.4.4 | ✅ | When AllowUpsert is enabled: if the entity already exists → 412 Precondition Failed; if not → proceeds as an insert. Requires GetById to check existence up front. A no-op when the header is absent or AllowUpsert is off |
Weak ETag prefix (W/) |
RFC 9110 §2.3 | ✅ | If-Match rejects weak validators; If-None-Match accepts them. RFC 9110 §13.1.1 requires strong comparison for If-Match and §8.8.3.2 says a weak validator can never participate in one, so a W/-prefixed entry is dropped, never unwrapped: If-Match: W/"<current-etag>" is a 412, while a weak entry alongside a matching strong one still succeeds on the strong one. If-None-Match uses weak comparison (§13.1.2), so W/"<current>" does match there. OhData never emits a weak ETag, so this only affects a client that constructs one itself. It is a deliberate divergence from Microsoft.AspNetCore.OData, which emits weak ETags unconditionally and compares them ignoring weakness, so If-Match: W/"..." is accepted there. If you are migrating from MS OData, a client that echoes back a W/-prefixed tag will now get 412 — send back exactly the ETag header value OhData gave you. See etags.md |
Response annotations
Citations name their document. This table draws on four: OData Part 1 (Protocol), OData JSON Format, OData Part 2 (URL Conventions) and RFC 9110. A bare
§4.5.3is ambiguous between them — Part 1 and JSON Format both have a section 4 — so every entry from a document other than Part 1 says which. Keep that when adding a row.
| Feature | Section | Status | Notes |
|---|---|---|---|
@odata.context on data responses |
Part 1 §10 | ✅ | Collections, entities, the service document, and single-valued navigation results. Not set on error responses; GET /$metadata is XML so the annotation doesn't apply there. |
@odata.context projection suffix with $select |
Part 1 §10.7/§10.8 | ✅ | $select narrows the context URL to the projected form (#Set(prop1,prop2) for collections, #Set(prop1,prop2)/$entity for a single entity), listing properties in the order the client requested them. Wired on all three collection-GET paths, GetById, and navigation-collection routes; omitted (context unchanged) when no $select is present |
@odata.count inline |
§11.2.5.5 | ✅ | When $count=true |
@odata.id entity self-link |
JSON Format §4.5.7 | ✅ | On GET, POST, PUT, PATCH responses. (Cited §4.5.8 until this sweep; that subsection is odata.editLink/odata.readLink.) |
@odata.etag in body |
JSON Format §4.5.9 | ✅ | When ETags configured. (Cited §4.5.3 until this sweep; that subsection is odata.type — see the row below.) |
@odata.type on a derived instance |
JSON Format §4.5.3 | ✅ | Emitted as #{Namespace}.{Type} whenever an instance's runtime type is derived from the type declared for the containing entity set or collection — §4.5.3 makes it a MUST in minimal or full metadata for exactly that case, and a client otherwise deserializes the row into the base type and silently drops its members. Covers collection rows, the single-entity read and expanded navigation values, and survives $select (it is control information, not a property). An instance of the declared type carries none, because the client determines that heuristically from @odata.context and §3.1.1 asks a minimal-metadata service to omit computable control information — Microsoft.AspNetCore.OData draws the same line. |
@odata.nextLink |
§11.2.5.7 | ✅ | When page size equals MaxTop |
Nav@odata.nextLink (nested server-driven paging) |
§11.2.5.7 / JSON §4.5.5 / JSON §24 item 15 | ✅ opt-in | JSON Format §24 item 15 — "MUST include the odata.nextLink control information in partial results for entity collections" — is a MUST once partial results are returned, and OhData never returns partial results without one. An expanded collection larger than MaxExpandTop is either rejected with 400 (returning no partial result at all, which the MUST does not reach) or, on a profile that sets both MaxExpandTop and ExpandPagingEnabled, served as its first MaxExpandTop children with Nav@odata.nextLink pointing at GET /{Set}({key})/{Nav}?$skip=N. Silent truncation exists in neither configuration. Emission is restricted to a truly bare $expand at depth 1; every other over-ceiling shape keeps the 400. Emitted in the 4.0 @odata.-prefixed form (the 4.01 short form is a SHOULD; OhData sends OData-Version: 4.0), and placed after the array — JSON §20.2 exempts nextLink from the "immediately prior" rule. Nav@odata.count and Nav@odata.nextLink never coexist: a nested $count=true makes an expand non-bare, so a paged nested collection never reports a count that would have to be the full one (§11.2.5.5). See query-options.md |
@odata.context on bound operations |
§10 | ✅ | Included when the function/action return type is the profile's model type or IEnumerable<TModel>. A recognized Edm-primitive return type (string, numeric types, bool, Guid, date/time types, byte[]) gets the JSON §11 individual-value envelope ({"@odata.context":".../$metadata#Edm.<Type>","value":<primitive>}); an arbitrary non-model, non-primitive return type is returned unwrapped |
OData-EntityId response header |
§8.3.3 | ✅ | On any 204 No Content that creates/upserts an entity (POST/upsert-PUT with Prefer: return=minimal); omitted on a plain update-PUT 204 |
Collection queries
| Feature | Section | Status | Notes |
|---|---|---|---|
$filter |
§11.2.5.1 | ✅ | Comparison, logical, arithmetic, string functions |
| Capability-flag enforcement ("parse or reject") | §8.2.1 / Minimal item 7 | ✅ | FilterEnabled/OrderByEnabled/SelectEnabled/ExpandEnabled/CountEnabled are enforced at runtime on every collection GET path (GetQueryable, GetAll, Priority-1) and on GetById ($select/$expand): a disabled option present in the request returns 400 (UnsupportedQueryOption) instead of being applied or silently ignored. 400 and not the 501 the row below carries: the service implements the option and this resource has switched it off, which is not §9.3.1's "functionality not implemented by the OData Service" |
| Unimplemented-option rejection ("parse or reject") | §9.3.1 / §11.2.5 / §8.2.1 / Minimal item 7 | ✅ | Any $-prefixed system query option a read route does not implement returns 501 Not Implemented (UnsupportedQueryOption) rather than being parsed and discarded under a 200 — on all three collection GETs, GET /{Set}/$count, GET /{Set}({key}), both branches of the navigation route (collection- and single-valued, with different implemented sets), its /$count, the $expand continuation, and the four bound and two unbound operation routes. The rule is the $ sigil against a per-route implemented set, not a closed name list, so an option this build has never heard of ($unknown, $slect, a top-level $levels, a future spec's addition) is refused rather than ignored (#359, #380, #353). Names are matched case-insensitively, matching Microsoft.AspNetCore.OData (ODataQueryOptions.IsSystemQueryOption lowercases before comparing whenever the URI resolver enables case-insensitivity, which is the default), so $Select/$TOP stay honoured. A key that does not begin with $ is a custom query option (Part 2 §5.2) and a @-prefixed key is a parameter alias (§5.3); neither is touched. $format is accepted on every route — §11.2.10 negotiation is handled once by the group filter and never reaches these handlers (on the two /$count segments it is accepted-and-ignored rather than negotiated, because §11.2.9 disallows content negotiation there; see the $count row). ($compute/$apply remain unimplemented per Known Limitations; this row is about rejecting them explicitly.) 501 is "can't"; 400 is "won't". The status is 501 because §9.3.1 makes it a MUST — "If the client requests functionality not implemented by the OData Service, the service MUST respond with 501 Not Implemented" — and Minimal item 7 names that same 501 inside its own MUST list; §11.2.5's SHOULD points the same way. $apply/$compute/$index/$deltatoken answer 501; the error code and message bytes are the same ones 400 carried. 400 is reserved for functionality the service does implement and this resource has switched off — a false capability flag, a property allowlist, a Search handler that was never supplied — and for a malformed option value on a route that implements the option. A corollary worth knowing: the same option can be 501 on one entity set and 400 on another — $filter is 501 on a GetAll-backed set (no IQueryable; the framework cannot filter it under any configuration) and 400 on a GetQueryable-backed set with FilterEnabled = false. Conformance is per-resource, and the two answers describe different conditions. Per-route implemented sets, the full 501/400 taxonomy, and the three route families still outside the rule (the structural-property routes, the service document and $metadata), are listed in query-options.md |
| Property allowlists | — (Capabilities vocabulary, [OData-VocCap]; not a Part 1 clause) | ✅ | FilterProperties/OrderByProperties/SelectProperties/ExpandProperties are enforced at runtime via the EDM's model-bound NotFilterable/NotSortable/NotSelectable/NotExpandable annotations: an option referencing a non-allowlisted property returns 400 (InvalidQueryOption). Exception: dynamic (open-type) properties are not in the EDM, so they carry no annotation and are not gated - Microsoft.AspNetCore.OData behaves identically; see docs/open-types.md#dynamic-keys-outside-allowlists and #401 |
round() midpoint rounding |
Part 2 §5.1.1.9 | ✅ | Round-half-away-from-zero by default (spec-compliant, e.g. 2.5 → 3, -2.5 → -3) via a post-ApplyTo expression rewrite on the GetQueryable path. Set profile/global RoundingMode = BankersRounding to restore .NET's default banker's rounding (2.5 → 2) - see Known Limitations for why that override exists, and docs/query-options.md#round-midpoint-rounding |
$orderby |
§11.2.5.2 | ✅ | Multiple keys, asc/desc |
$top |
§11.2.5.3 | ✅ | MaxTop server-side cap enforced on all three collection paths (GetQueryable, GetAll, Priority-1). An explicit $top above MaxTop returns 400; an omitted $top is capped to MaxTop (or a smaller Prefer: maxpagesize) with a @odata.nextLink continuation on every path. GetAll applies it as a post-materialization Take() and emits a $skip link; set MaxTop = null to opt a path out of the omitted-$top cap (unbounded, no nextLink). See docs/query-options.md |
$skip |
§11.2.5.4 | ✅ | On GetAll, applied as a post-materialization Skip() |
$count (inline and standalone) |
§11.2.5.5 / §11.2.9 | ✅ | Reports the pre-paging total; on the ODataEntitySetProfile (GetODataQueryable) path a profile that applies its own $top/$skip must set ODataQueryResult.TotalCount or @odata.count falls back to the post-page item count. On the standalone GET /{Set}/$count segment, $filter is the one data option applied; $search is not implemented there and, since #353, returns 501 (UnsupportedQueryOption) instead of the unfiltered total under a 200. Use GET /{Set}?$search=…&$count=true and read @odata.count, which does honour it. §11.2.9 partitions the rest of the options and the segment follows it: $top, $skip, $orderby and $expand are accepted and ignored, because the clause says in terms that "The returned count MUST NOT be affected by" them, and under Minimal item 7's "either follow the specification or return 501" ignoring them is the follow arm. $select is ignored on the same reasoning though the clause does not name it — it changes an item's shape, never its membership, and the body is a bare scalar. This segment negotiates nothing: §11.2.9 says content negotiation "is not allowed" with /$count, so both $format and Accept are accepted and ignored and the body is text/plain regardless — $format=xml and Accept: application/xml each answer 200 with the count. Microsoft.AspNetCore.OData settles it the same way: ODataCountMediaTypeMapping matches every /$count path at quality 1 and ODataOutputFormatter.CanWriteResult then overrides the content type, so MS never negotiates and never 406s here. §11.2.9 is the specific rule over Minimal item 5.1's general "MUST conform to the semantics [of] Accept ... or fail the request". An ordinary read still 406s a client that refuses JSON — the negotiation filter skips this segment rather than widening what it produces. $apply/$compute/$count and any unrecognized $-name fall outside the clause and are refused. This agrees with Microsoft.AspNetCore.OData, whose ODataQueryOptions.ApplyTo returns early on Request.IsCountRequest(), and with Microsoft.OData.Client, which appends /$count to an already-built query string and strips nothing — so q.OrderBy(…).LongCount(), q.Take(n).LongCount() and q.Skip(n).LongCount() all work (pinned end-to-end in OhData.MicrosoftODataClient.Tests) |
$search |
§11.2.5.6 | ✅ | Requires a Search handler; 400 Bad Request (UnsupportedQueryOption) if unset — 400 rather than 501 because the route has a $search leg and the functionality is merely unconfigured on that profile. On a route with no $search leg at all (/$count, GET /{Set}({key})) the option is 501 by the sigil rule. On the GetQueryable/GetAll paths Search replaces the source and the framework applies the remaining options on top. Not available on the Priority-1 (GetODataQueryable) path, which hands the whole ODataQueryOptions to the profile and so has no seam to feed a search-derived source into without bypassing it; that combination is refused at startup rather than advertised and ignored, and $search there is the profile's own business via options.Search |
$select |
§11.2.4.1 | ✅ | On the GetQueryable/EF path an eligible $select pushes a column-pruned projection to SQL (SelectPushdownEnabled — on by default); JSON post-processing applies the selection on the GetAll/Priority-1 paths and as the fallback for ineligible requests |
$expand |
§11.2.4.2 | ✅ | The expansion pipeline runs identically on the GetQueryable, GetAll, and Priority-1 ODataQueryOptions paths and on the single-entity GET /Set({key}) route. A delegate-less HasMany/HasOptional/HasRequired is folded into an EF Core SQL JOIN (ExpandPushdownEnabled — on by default), including nested/multi-level/$levels, and including a standard bidirectional relationship (a related type is materialized through a fresh member-init projection at every level including leaves, which forecloses a serialization cycle structurally regardless of back-references); a delegate-backed navigation is resolved by its registered handler per entity (or once per page via a batch handler — no EF Core dependency). Ineligible pushdown (non-EF provider, non-projectable AND cyclic) degrades to the delegate/EDM-only path — safely: response serialization itself is clause-bounded, not object-graph-bounded (the SerializeBounded walker, JSON §4.5.1), so a self-referential/bidirectional entity set does not 500 regardless of which path served it, whole-graph $expand or plain GET. |
$skiptoken (server-driven paging) |
§11.2.5.7 | ✅ | Base64-encoded raw skip offset (a 4-byte little-endian int) - not an opaque/obfuscated cursor. Predictable and forgeable by clients. |
Entity operations
| Feature | Section | Status | Notes |
|---|---|---|---|
| Get entity by key | §11.2.2 | ✅ | |
| Create entity (POST) | §11.4.2 | ✅ | Returns 201 Created + Location header (§8.3.2). Content-Location is also set — an HTTP courtesy (RFC 9110 §8.7), not an OData requirement; Part 1 never mentions it |
| Update entity (PUT) | §11.4.3 | ✅ | Full replacement |
| Update entity (PATCH) | §11.4.3 | ✅ | Partial update |
| Delta PATCH | §11.4.3 | ✅ | Via the base EntitySetProfile.Patch delegate - the framework builds a Delta<TModel> containing only the properties present in the request body and passes it to the handler, which typically calls delta.Patch(existing) |
| Delete entity | §11.4.5 | ✅ | Delete returns Task<bool>; false → 404 or 204 depending on IdempotentDelete (defaults to true, i.e. 204) |
| Upsert via PUT | §11.4.4 | ✅ | AllowUpsert = true |
| Key validation on PUT/PATCH | §11.4.3 | ✅ | URL key must match body key; 400 on mismatch |
| Request body validated against the EDM's nullability | — (framework rule; see the note) | ✅ | A property the body names with an explicit null, where the framework's own $metadata declares it Nullable="false", is answered 400 (code: "InvalidBody", target: the property) before the handler runs — previously it reached the handler and the persistence layer's rejection surfaced as a generic 500. Applies uniformly to POST, PUT, PATCH, the navigation-POST create route and the structural-property writes — one code and one message across all five which found three wordings and two code values shipping for that one condition (the property writes answered BadRequest). The wording also has to be true when a PropertyNamingPolicy meant the binder never bound a value the client did send, so it states that no non-null value was supplied rather than that the client sent null. An omitted property is not a violation on any verb: §11.4.2's only MUST-fail is "The service MUST fail if unable to persist all property values specified in the request" — about values that were sent — and it permits omission outright for two named categories, "Properties computed by the service (annotated with the term Core.Computed …) and properties that are tied to properties of the principal entity by a referential constraint". No clause in Part 1 mandates a 400 for an omitted property. The nearest one, §11.4.3, is PUT-only and prescribes the opposite remedy: "Missing non-key, updatable structural properties not defined as dependent properties within a referential constraint MUST be set to their default values" — a statement about what the service stores, which OhData leaves to the handler that owns persistence. Microsoft.AspNetCore.OData accepts omission and rejects an explicit null in exactly the same way. Four properties are outside the rule: the entity key, a non-nullable value type (an explicit null there is already a deserializer-worded 400), a member no readable CLR property backs, and anything the EDM does not declare — which exempts Ignore()d properties. Per-entity-set opt-out: RequestBodyNullabilityValidationEnabled = false. Nullability inside a nested complex value is not checked |
| Deep insert (nested related entities in POST) | §11.4.2.2 | ✅ | AllowDeepWrites = true (profile-level, entity-level granularity — no per-navigation opt-in). Rides the existing Post handler; no new route/delegate. Default (false): nested navigation-property values are stripped (set to null) before Post is invoked. Opt-in (true): the full deserialized graph is passed to Post, which owns atomic persistence (e.g. one EF Core SaveChanges); the 201 response echoes the handler's return value, including populated nested navigation values. See docs/deep-insert.md |
| Deep update (nested related entities in PUT/PATCH) | 4.01 §11.4.3.1 | ❌ | Not implemented, and enforced rather than only documented: with AllowDeepWrites at its default of false, a nested navigation value in a PUT body is stripped before Put is invoked and one in a PATCH body never enters the Delta<TModel> — the same strip set the collection POST uses. Set AllowDeepWrites = true to receive the graph and own it yourself; OhData still creates/updates/deletes nothing related on your behalf. See docs/deep-insert.md |
@odata.bind (link existing entity during insert) |
JSON format §8.5 | ❌ | Not implemented — detected anywhere in a POST body (top level or nested) and rejected with 501 Not Implemented rather than silently ignored. The other write routes (PUT, PATCH, navigation-POST, structural-property writes, action parameters) give the same 501, on every registration. Use $ref endpoints to link existing entities |
Navigation and links
| Feature | Section | Status | Notes |
|---|---|---|---|
| Navigation property routes | §11.2.6 | ✅ | GET /Set({key})/Nav. Both the collection and single-valued (HasOptional/HasRequired) branches carry @odata.context (single-valued context: #Set(key)/Nav/$entity) |
Navigation $count |
§11.2.6 / §11.2.9 | ✅ | GET /Set({key})/Nav/$count. A missing parent returns the OData error envelope (404), not an empty body |
Navigation with $select |
§11.2.6 / §11.2.4.1 | ✅ | Collection navigation only; narrows the response body and the context URL's projection suffix (see @odata.context projection suffix above) |
Navigation $top/$skip validation |
Part 2 §5.1.6 | ✅ | An invalid (non-numeric or negative) $top/$skip on a navigation-collection route returns 400 Bad Request (InvalidQueryOption), matching the main collection route's validation, instead of being silently ignored and returning the full un-paged collection |
| Navigation unsupported-option rejection | §9.3.1 / Minimal item 7 | ✅ | Every $-prefixed option other than $select/$orderby/$skip/$top/$count (plus $format) on GET /{Set}({key})/{Nav} returns 501 (UnsupportedQueryOption) rather than being silently ignored — $filter, $expand, $search, $apply, $compute, $skiptoken, $deltatoken and, anything unrecognized. The single-valued navigation branch of that same URL shape (HasOptional/HasRequired) reads no query option at all, so it accepts $format and refuses everything else, $select included — gating it with the collection branch's set left $select/$orderby/$top/$count accepted-and-dropped under a 200. The companion GET /{Set}({key})/{Nav}/$count follows §11.2.9 exactly as the entity-set /$count does, and reaches a stricter answer in one class only because it applies less: it invokes the navigation delegate and counts the result, so it can apply neither of the two options §11.2.9 says a count is taken after applying and refuses both $filter and $search — ignoring either would answer a wrong number under a 200. The four the same clause says the count MUST NOT be affected by ($top, $skip, $orderby, $expand), plus $select and $format, are accepted and ignored; $count, $apply, $compute and any unrecognized $-name are refused. |
$expand continuation route |
§11.2.6 / Minimal item 3, item 7 | ✅ opt-in | GET /{Set}({key})/{Nav}?$skip=N — registered only on a profile with both MaxExpandTop and ExpandPagingEnabled set, and only for a collection-valued navigation whose element type has a single resolvable key and which that profile's own declaration leaves delegate-less — the same candidate set (the URL-named profile alone) the root read path resolves against, so a route can never serve a navigation the $expand beside it does not already serve raw (#421). It is the target of Nav@odata.nextLink (see Response annotations above) and implements server-driven paging for the nested case, satisfying Minimal item 3 there rather than truncating. It accepts $skip only: every other system query option returns 501 (UnsupportedQueryOption), rejected by the $ sigil so an option this build has never heard of is refused rather than ignored (Minimal item 7). $format is the one exemption and is not a data option — §11.2.10 negotiation is handled once by the group filter that wraps the whole OData surface, never reaches this handler, and cannot change a row; an unsupported $format value is still rejected there. The context URL uses the same parent-path shape as the ordinary navigation route (see Declared deviations). Ordering is a total order on the child key, composed unconditionally on both the first page and every continuation |
$ref get link(s) |
§11.4.6.1 | ✅ | GET /Set({key})/Nav/$ref returns populated @odata.id (collection or single) when refTargetEntitySet is configured on the navigation; otherwise an empty envelope. Context URL is #$ref (single-valued) or #Collection($ref) (collection), per JSON Format §14 / Protocol §10.12 |
$ref add link |
§11.4.6.1 | ✅ | POST /Set({key})/Nav/$ref (collection navigations) / PUT /Set({key})/Nav/$ref (single-valued navigations). Malformed/non-object/empty body → 400; non-JSON Content-Type → 415 |
$ref remove link |
§11.4.6.2 | ✅ | DELETE /Set({key})/Nav/$ref |
| POST related entity via navigation | §11.4.2.1 | ✅ | POST /Set({key})/Nav — collection navigations only, via the post parameter on HasMany. 201 Created (Location/@odata.id when refTargetEntitySet is configured); Prefer: return=minimal → 204 + OData-EntityId; handler returning null → 404 (parent not found); malformed body → 400; non-JSON content type → 415. No post handler → route not registered (405 from the coexisting GET nav route) |
Individual property access
| Feature | Section | Status | Notes |
|---|---|---|---|
| Get individual property | §11.2.6 | ✅ | GET /Set({key})/Prop — rides the existing GetById handler; PropertyAccessEnabled (default true) gates it, requires GetById to be configured. Returns the {"@odata.context":...,"value":...} envelope |
| Null property value | §11.2.6 | ✅ | 204 No Content |
| Get individual property raw value | Part 2 §4.6/4.7 | ✅ | GET /Set({key})/Prop/$value — text/plain for primitives (invariant culture), application/octet-stream for byte[] |
| Raw value of a null property | Part 2 §4.7 | ✅ | 404 Not Found — the raw value does not exist |
| Raw value of a complex property | Part 2 §4.7 | ✅ | 400 Bad Request — no raw representation; use the non-$value envelope form instead |
| Property-route/bound-function collision detection | — | ✅ | Startup validation (app.MapOhData()) throws InvalidOperationException if an entity-level bound function shares a name with a structural property |
Update individual property (PUT/PATCH) |
§11.4.9.1/.2 | ✅ | PUT/PATCH /Set({key})/Prop with body {"value":...} — rides the existing Patch handler (built as a one-property Delta<TModel>); registered when PropertyAccessEnabled and Patch are both configured. PUT full-replaces complex properties; PATCH on a complex property is documented non-support (400, see below) |
Set property to null (DELETE) |
§11.4.9.3 | ✅ | DELETE /Set({key})/Prop — 204 on a nullable property, 400 on a non-nullable property |
| Key property write | §11.4.9 | ✅ | PUT/PATCH/DELETE on the key property always 400 Bad Request — the key is immutable |
PATCH (partial merge) on a complex property |
§11.4.9.2 | ❌ | Documented non-support — PUT full-replacement is supported; merge is not. Returns 400 Bad Request rather than a bare 405 |
PUT /Set({key})/Prop/$value (raw-value write) |
§11.4.9.1.2 | ❌ | Not supported — raw /$value remains read-only; use the enveloped PUT .../{Property} form |
Bound operations
| Feature | Section | Status | Notes |
|---|---|---|---|
| Collection-bound functions | §11.5.3 | ✅ | GET /Set/FunctionName?params |
| Collection-bound actions | §11.5.4 | ✅ | POST /Set/ActionName (JSON body). Malformed/non-object/empty body → 400; non-JSON Content-Type → 415 (only when the action has parameters — a parameterless action never reads the body) |
| Entity-bound functions | §11.5.4 | ✅ | GET /Set({key})/FunctionName?params |
| Entity-bound actions | §11.5.4 | ✅ | POST /Set({key})/ActionName (JSON body). Same body-shape/Content-Type guards as collection-bound actions |
| Unbound functions | §11.5.3 | ✅ | GET /FunctionName?params. Unlike the bound/entity-bound rows above, the result is returned as a bare JSON body with no @odata.context/individual-value envelope, even for a model or Edm-primitive result — see docs/bound-operations.md#unbound-functions-and-actions |
| Unbound actions | §11.5.4 | ✅ | POST /ActionName. Same body-shape/Content-Type guards as bound actions; same unenveloped-response caveat as unbound functions above |
Prefer header
| Feature | Section | Status | Notes |
|---|---|---|---|
Prefer: return=minimal |
§8.2.8.7 | ✅ | POST/PUT/PATCH return 204; Preference-Applied set |
Prefer: return=representation |
§8.2.8.7 | ✅ | Preference-Applied set in response |
Prefer: maxpagesize |
§8.2.8.5 | ✅ | Both spellings are accepted on the request (odata.maxpagesize is the OData 4.0 name; maxpagesize the 4.01 rename), and Preference-Applied always echoes the 4.0 spelling odata.maxpagesize whichever was sent — this service reports OData-Version: 4.0, so echoing the 4.01 token claimed a preference that version does not define (#372). On the root collection it is applied as the page size when $top is absent, capped at MaxTop: the honored page size is min(maxpagesize, MaxTop). On a nested ($expand) collection it narrows the page to min(maxpagesize, MaxExpandTop), but only on the shape that also emits a Nav@odata.nextLink; the same header narrows the $skip continuation route. Preference-Applied is a single header carrying the value actually applied, not the value the client requested — the echo's own token spelling is #372. |
Error responses
| Feature | Section | Status | Notes |
|---|---|---|---|
error.code and error.message |
§9.3 | ✅ | All error responses, including malformed/wrong-shaped POST, PUT, and PATCH request bodies and unsupported Content-Type values (400/415) - these read and deserialize the body manually rather than relying on ASP.NET Core's implicit body-binder, which used to short-circuit with an empty 400/415 body before this formatting code ran. The same manual-read/guard pattern also covers every route that reads a JSON body by hand: entity-bound actions, collection-bound actions, unbound actions, and $ref POST/PUT |
error.target |
§9.3 | ✅ | Set on key-mismatch and invalid-key errors |
error.details array |
§9.3 | ⚠️ | The internal ODataError helper accepts a details parameter and will serialize it, but no call site in the framework currently populates it - the array never appears in a real response today |
| Unhandled handler exceptions | §9.4 | ✅ | A group-level endpoint filter wraps every route (added alongside the OData-Version/OData-MaxVersion filters) and converts any exception a handler throws — as opposed to an ODataError result a handler deliberately returns — into a 500 with the standard error envelope, code: "InternalServerError", and a generic message. The real exception is logged (category "OhData") but its message/stack trace is never included in the response body. A handler-thrown Microsoft.OData.ODataException or FormatException is not claimed as a client error: only the framework's own key parser and option construction produce those 400s. Both reach this filter now. It is not the outermost group filter (the observability filter is added first and wraps it), so an exception raised inside that filter's own body or its Response.OnCompleted callback still escapes the envelope — accepted deliberately, since reordering would cost trace correlation on this filter's own LogError |
Service document and metadata
| Feature | Section | Status | Notes |
|---|---|---|---|
Service document (GET /) |
§11.1 | ✅ | Lists every entity set, plus each function import whose CSDL IncludeInServiceDocument is set — i.e. the parameterless ones, per CSDL 4.0 §13.6. Action imports are never listed. Generated from the same EDM container $metadata is written from, so the two cannot advertise different surfaces. |
CSDL metadata (GET /$metadata) |
§11.1 | ✅ | Full EDM XML. Validated with EdmValidator.Validate at MapOhData(): an invalid construct (an IncludeInServiceDocument claim on a parameterized import, an operation name that is not an odataIdentifier) fails startup naming the construct, rather than reaching consumers that validate. Note the asymmetry — CsdlReader.TryParse accepts both, so a consumer that merely parses would survive while a codegen tool would not. |
| Entity set declarations | §9.1 | ✅ | |
| Navigation property declarations | §9.1 | ✅ | |
| Bound function/action declarations | §9.1 | ✅ | |
| Unbound function/action declarations | §9.1 | ✅ |
Known limitations
| Feature | Notes |
|---|---|
SQL column projection for $select |
Pushed to SQL on the GetQueryable/EF path by default; ineligible requests (no parameterless ctor, setterless projected member, non-EF provider, or SelectPushdownEnabled = false) fall back to fetching all columns + trimming the response JSON |
| ETag check atomicity | GET-then-write has a race window; use a database-level mechanism for true atomistic concurrency |
If-Match is ignored on collection-bound and unbound actions |
POST /{Set}/{Action} and POST /{Action} have no {key} segment and no addressed entity, so there is nothing to load an entity tag from; §11.5.4.1's "or collection of entities" half would need a collection ETag, which this framework does not compute. A conditional header on those two routes is discarded and the action runs. Entity-bound actions (POST /{Set}({key})/{Action}) are covered — #566 brought them under the precondition gate, closing a §11.4.1.1 MUST violation. Earlier revisions of this page justified the wider exclusion by claiming an action-invocation resource "has no representation" and citing §11.5.4; that phrase does not appear anywhere in Part 1, and §11.5.4.1 in fact tells the client to send If-Match for exactly this case |
If-None-Match on POST |
Not implemented; validate in the Post handler if needed. (If-None-Match: * on PUT is implemented as a create-guard — see Request conditional headers above.) |
$compute |
Unimplemented. Microsoft.AspNetCore.OData is pinned to [9.4.*, 10) on all target frameworks (including net10.0), which deliberately excludes the v10+ release that adds $compute support - the blocker is the package version pin, not the target framework. |
| JSON batch requests | Not supported |
Nested paging is limited to a truly bare $expand at depth 1 |
Nav@odata.nextLink is emitted only for a collection $expand carrying no nested options ($skip=0 and $count=false are the two identity no-ops that still count as bare) directly under the URL-named entity set. Depth ≥ 2 stays 400 over the ceiling: a level with its own nested $expand cannot be SQL-bounded at all (the APPLY/LATERAL constraint), so it is unbounded in materialization whatever the response says, and a link there would advertise a bound that does not exist. Any nested $filter/$orderby/$select/$skip>0/$count=true/$levels, and any navigation whose element type has a composite or unresolvable key, likewise keep the 400 — a $skip-only continuation cannot carry a nested option, and without a single key there is no total order to walk. Deliberate; see query-options.md and #410 |
Delegate-backed navigations are not bounded or paged by MaxExpandTop/ExpandPagingEnabled |
A navigation declared with a handler is never in the engaged pushdown tree, so no SQL bound, no ceiling check and no continuation link apply to it, and its size is entirely the handler's responsibility. (Nested options on one are applied where they can be and refused where they cannot, never dropped: $filter/$orderby/$top/$skip are bound by the same binders as the pushdown path and applied in memory since #650, with $select and $count likewise from the materialized children. MaxExpandTop is still not imposed — only the window the client asked for. Execution here is LINQ-to-Objects, not SQL — see query-options.md.) Bounding it would mean the framework silently truncating a collection the developer's delegate deliberately returned — a direct weakening of the delegate-safety invariant — so the intended fix is a contract change (a delegate overload taking (key, skip, take, ct)), not a ceiling applied behind the delegate's back. #410 |
$levels=N and the explicit nested $expand of the same self-referential descent can return different data |
Only when the node type is exposed by several entity sets that disagree about the self-navigation (one declares it delegate-less, another declares it with a handler). $levels recurses the URL-named set's own already-resolved binding at every level, so that set stays authoritative and the descent serves raw. The explicit spelling descends one real expand item per level, so each level re-resolves its candidate set from every entity set exposing the type; a disagreement there fails closed, and because a non-serve-raw child defers the whole branch off pushdown, the parent level comes back empty too — not merely the grandchild. Measured on one node type behind a delegate-less and a delegate-backed set: ?$expand=Children → both children; ?$expand=Children($levels=2) → both levels; ?$expand=Children($expand=Children) → "Children": []. Fail-closed and leak-safe, and settled as the ship behaviour (owner micro-decisions A and B on #293); unifying the two under "serve raw" needs parent-set provenance threaded through the descent. Does not arise when only one entity set exposes the type, which is the common case. #318 |
Prefer: odata.maxpagesize narrows a nested page only where a nested nextLink is emitted |
§8.2.8.5 scopes the preference to "each collection within the response", and as of #412 OhData honours it on a nested $expand collection — but only on the shape that also gets a Nav@odata.nextLink (a truly bare expand on an ExpandPagingEnabled profile), since trimming a collection with no continuation would be silent truncation. Clamped down to MaxExpandTop, never up, and it never lowers the ceiling, so it cannot turn a 200 into a 400. The continuation route reads the same header (§8.2.8.5: "the client MAY specify a different value for this preference with every request following a next link"), so page sizes may legitimately differ between hops; $skip is absolute and advances by the rows each hop served, so nothing is skipped or repeated. Preference-Applied stays a single header with a single value, per the same section's MAY and its "the maximum page size applied" wording — no per-collection echo is emitted. |
error.details array |
Mechanism exists in the ODataError helper but is currently dead code - no call site populates it |
round() + RoundingMode.SpecCompliant may not translate on every EF Core provider |
The spec-compliant rewrite emits Math.Round(value, MidpointRounding.AwayFromZero), which not every EF Core provider can translate to SQL - a query using round() may throw a translation exception. Set RoundingMode = BankersRounding (per-profile or via EntitySetDefaults) to fall back to the single-argument Math.Round overload the provider could already translate, at the cost of reverting to banker's rounding on midpoints. |
Priority-1 GetODataQueryable path does not inherit RoundingMode |
The profile calls ApplyTo itself on that path, so the framework's post-ApplyTo rounding rewrite never runs against it - round() keeps .NET's default banker's-rounding semantics there regardless of RoundingMode, unless the profile applies the same rewrite manually. |
Unbound functions/actions have no @odata.context envelope |
Their results are always returned as a bare, unenveloped JSON body, unlike bound/entity-bound operations - see the "Bound operations" table above and docs/bound-operations.md#unbound-functions-and-actions. (They do carry per-operation authorization: AddFunction/AddAction take an optional authorize lambda. Before that, only group-level MapOhData().RequireAuthorization() could protect them, which also covered $metadata. RequireResource() is refused there - there is no {key} entity to evaluate against. See docs/authorization.md.) |
Declared deviations
Deviations specifically from
Microsoft.AspNetCore.OData, and the places OhData deliberately matches it where the specification left room, are collected with source citations in differences-from-microsoft-odata.md.
These are intentional, permanent design choices rather than bugs to be fixed - the code will not change to "correct" them.
| Deviation | Notes |
|---|---|
Priority-1 GetODataQueryable @odata.count is the profile's contract |
On the ODataEntitySetProfile/IODataEntitySetEndpointSource path, the profile applies $top/$skip itself and returns an ODataQueryResult<TModel>. @odata.count is not second-guessed: if the profile omits TotalCount, @odata.count reflects only the returned page's item count (not the true total), so a profile that pages itself must set ODataQueryResult.TotalCount explicitly. Paging, however, is now enforced by the framework: if the profile does not set NextLink and the client omits $top, the framework caps the materialized result to MaxTop (or a smaller Prefer: maxpagesize) and emits an @odata.nextLink continuation - so this path cannot return an unbounded set. That continuation carries its offset in a framework-private custom query option (ohdata-skiptoken) which the framework applies itself rather than leaving the skip to the profile; see $top and $skip. An oversized $top is rejected with 400 on this path too. A profile-supplied NextLink still takes priority and disables the framework cap. See ODataQueryResult<TModel> in src/OhData.AspNetCore/ODataQueryResult.cs. |
$expand continuation for a nonexistent parent key is 200 + empty value, not 404 |
GET /{Set}({key})/{Nav}?$skip=N (the Nav@odata.nextLink target) answers a key that matches no entity with 200, an empty value array and no link. Microsoft.AspNetCore.OData returns 404 for the equivalent request. The route composes parents.Where(p => p.Key == k).SelectMany(p => p.Nav), and a SelectMany cannot distinguish "no such parent" from "a parent that has no children" — both produce zero rows. Telling them apart requires an existence probe, i.e. a second round trip on every continuation, to improve the status code of a request a conforming client never issues: it only ever follows a link the server emitted, which by construction names a parent that existed. Contrast the delegate-backed navigation route on the same URL shape, where the handler decides and returning null does produce 404. Recorded as an accepted limit in #410. |
Navigation-collection @odata.context uses the parent-path shape |
GET /{EntitySet}({key})/{Nav} responses use #{EntitySet}({key})/{Nav} as the context fragment (the path that produced the result) rather than #{TargetEntitySet} (the target entity set's own name), even when the navigation's target entity set is independently addressable. This is a deliberate reading of §10.4 ("the context URL... identifies the type of the payload by ... the last segment of the request URL that identifies a type"), which permits the parent-relative form; it favors traceability back to the request over resolvability to the shortest canonical set name. |