The Open Data Protocol (OData) is an open protocol for sharing data. It provides a way to break down data silos and increase the shared value of data by creating an ecosystem in which data consumers can interoperate with data producers in a way that is far more powerful than currently possible, enabling more applications to make sense of a broader set of data. Every producer and consumer of data that participates in this ecosystem increases its overall value. OData is consistent with the way the Web works – it makes a deep commitment to URIs for resource identification and commits to an HTTP-based, uniform interface for interacting with those resources (just like the Web). This commitment to core Web principles allows OData to enable a new level of data integration and interoperability across a broad range of clients, servers, services, and tools.
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Gaining the Knowledge of the Open Data Protocol (OData)
1. Gaining the Knowledge of the
Open Data Protocol (OData)
Chris Woodruff
Director, Perficient
Level: Intermediate
2. Who I am?
Chris Woodruff
MVP, Visual C#
Director at Perficient
Co-host of Deep Fried Bytes Podcast
@cwoodruff / cwoodruff@live.com / Skype: cwoodruff
3. You will learn:
•
Understand the background of OData
•
Have an understanding of the OData
protocol
•
How to produce an OData feed using
WCF Data Services
•
How to produce an OData feed using
ASP.NET Web API
•
How to consume an OData feed using
LINQ
5. Quote
Jim Gray
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.
16. The Basics of OData
Feeds, which are Collections of typed
Entities
OData services can expose Actions and
Functions (v4), Services (v3)
OData services expose all these constructs
via URIs
OData service may also expose a Service
Metadata Document
17. Full SQL like Query “Language”
HTTP Command
(Verb)
GET
SQL
Command
SELECT
PUT
UPDATE
POST
INSERT
DELETE
DELETE
24. Atom Format
•
•
•
Atom parsers exist in many frameworks
Element fields can be mapped to their
Atom counterparts
A good example of OData interoperability
25. What else can you do with OData?
•
•
•
Actions and Functions allow hypermediabased method calls (non-CRUD
operations)
Defined conventions for PATCH and deep
insert
Vocabularies
26. OData isn’t always the best fit
•
•
•
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
27. OData does not support all queries
•
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
35. OData Best Practices (Producer)
•
•
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
37. What if Data API’s were like…
LINQ?
•
What are the last 50 invoices we sent?
– context.Invoice.OrderByDescending(i=>i.PostedAt).Take(50);
•
What are the invoices from the last 24 hours?
– context.Invoice.Where(i=>i.PostedAt > DateTime.Now.AddDays(-1));
•
How many $1M invoices have we sent?
– context.Invoice.Where(i=>i.TotalAmount >= 1000000);
39. OData Best Practices (Consumer)
•
•
•
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 paging.
Design and implement a client-side data
caching function in your app (unless
sensitive data).