Gaining the Knowledge of the Open Data Protocol (OData)
GAININGTHE KNOWLEDGE OF
THE OPEN DATA PROTOCOL
WHO I AM?
Director at Perficient
Co-host of Deep Fried Bytes Podcast
@cwoodruff / firstname.lastname@example.org
Understand the background of OData
Have an understanding of the OData protocol
How to produce an OData feed using WCF Data
How to produce an OData feed using ASP.NET
How to consume an OData feed using LINQ
Today, the tools for capturing
data both at the mega-scale
and at the milli-scale are just
dreadful. After you have
captured the data, you need
to curate it before you can
start doing any kind of data
analysis, and we lack good
tools for both data curation
and data analysis.
Problem: Data APIs frequently
create more problems than
THISTALK IS ABOUT ONE SOLUTION.
…knows what the web is
…are comfortable w/ HTTP and
…have a basic understanding of
the term REST
…have created a Data API
Is there really a problem?
What is it?
FACEBOOK: WHAT FIELDSWILL I
GETWHEN I READ A POST?
THE BASICS OF ODATA
Feeds, which are Collections of typed Entities
OData services can expose Actions and Functions (v4),
OData services expose all these constructs via URIs
OData service may also expose a Service Metadata Document
FULL SQL LIKE QUERY
90% more compact than AtomPub
Reads like a custom API
Very little OData “gunk”
Atom parsers exist in many frameworks
Element fields can be mapped to their Atom
A good example of OData interoperability
WHAT ELSE CANYOU DO WITH
Actions and Functions allow hypermedia-based
method calls (non-CRUD operations)
Defined conventions for PATCH and deep insert
ODATA ISN’T ALWAYSTHE BEST
OData may not be a good fit for highly opinionated APIs
laden with developer intent
OData may not be a good fit for bulk data transfer
OData may not be a good fit for the APIs that dramatically
different in shape than the backend
ODATA DOES NOT SUPPORT ALL
OData doesn’t currently support aggregation
You can’t ask for customers that have at least 2 orders
OData doesn’t currently support filters expansions
You can’t ask for a customer and only their orders placed in 2013
OData doesn't support “graph” queries
You can ask friend-of-a-friend type queries, but there are limitations
ODATA IS A STANDARD!!
Ratified in March!
ODATA BEST PRACTICES
Always design your OData feed will server-side paging if your
entity collections hold large amounts of data.
Looks at server-side validation of queries and data updates
based on the user credentials sent through HTTP
WHAT IF DATA API’S WERE LIKE…
What are the last 50 invoices we sent?
What are the invoices from the last 24 hours?
How many $1M invoices have we sent?
context.Invoice.Where(i=>i.TotalAmount >= 1000000);
ODATA BEST PRACTICES
Use Query Projection to only bring back the entity properties
you or your app needs.
Think about client-side paging even if their exists server-side
Design and implement a client-side data caching function in
your app (unless sensitive data).