Brian Noyes is CTO and Architect at Solliance, an expert technology solutions development company. Brian is a Microsoft Regional Director and MVP, and specializes in rich client technologies including XAML and HTML 5, as well as building the services that back them with WCF and ASP.NET Web API.
Introduction to ASP.NET Web API Services and OData In this module, we're going to get started by talking about some of the fundamentals of ASP. NET API. I'm going to talk about its capabilities and how you go about building services with it. I'll also introduce you to the REST architectural style and what that means. And we'll talk about how to build a basic CRUD oriented web API service, even without any OData involvement. Then we'll finish off this module by talking about the OData protocol at a high level, talking about its features and capabilities. First, I'm going to go into some of the fundamentals of the ASP. NET Web API and a service development technology stack. I'll cover what its capabilities and features are and what some of the core concepts are that you need to know when using the web API. Next, I'll talk a little bit about what's going on under the covers of web API. We'll talk about some of the underlying architecture and how messages pass through the system and what the components are that are involved in processing the messages for web API. I'll also talk about the configuration you set up in your host environment so that you can influence how web API does its job. Then, I'll get into REST fundamentals. The REST architectural style is a different way of thinking about doing services if you've been exposed to service oriented architecture and other technologies like Windows Communication Foundation. So I'll talk about what composes the REST architectural style and what's different about it. Next, I'll talk about defining basic CRUD services with the web API. So CRUD standing for create, read, update, delete, standard acronym there for data oriented services and we'll see what it looks like to define one of those with the web API and I'll go through a demo showing you how to do that. Finally, I'll talk about the OData protocol at a very high level, letting you know its features and capabilities to prepare you for the rest of the course.
OData Platform, Tools and Resources In this module, I'm going to talk about the OData Platform, tools, and resources. So I basically want to give you a sense of the broader ecosystem of OData as a whole so that you can see some of the benefits of using it in the multiplatform aspect of it. First, I'm going to go into OData support across multiple server platforms, so focusing on the server side and talking about the many different ways you can expose OData, and a lot of these you'll see are things you're probably already using in your systems and in your applications and you may not even realize that they support OData themselves. Next, I'm going to compare and contrast WCF Data Services and Web API OData. At a high level, they both seem to do the same thing, so the question often arises when should I use one or the other. Next, I'll talk about WCF Data Services and give you a sense of what does it look like to implement OData Services with that platform and I'll do a quick demo there so that you have that to compare and contrast yourself as we dive into the details of doing it with Web API in the rest of the course. And I'll finish this module by talking about some of the OData tools and libraries that are out there for implementing client applications and for consuming OData, both for debugging and diagnostic purposes and just for general querying and consumption of the data.
Supporting OData Query Syntax In this module, I'm going to introduce you to OData Query Syntax and you'll see how to support it in your web API services, as well as understand what goes on under the covers when an OData query comes in. First I'm going to talk about the query syntax itself and what goes into the URL and how the information gets encoded. And we'll see some demos of various queries executing against an OData service. Next, I'll talk about how to go about adding queryable support or support for the OData query syntax to your web APIs. And you'll see it's very simple, there's an attribute that you would add and add the NuGet package and basically return something a little different from your services. So we'll talk about that in a quick slide, and then we'll demonstrate how you go about doing it. Finally, we'll talk about deferred execution, which is something that becomes enabled when you start doing OData queries against a LINQ provider. And it's basically the fact that the client can issue a query, which can be merged with the server side query and executed a couple tiers away at the database instead of having to execute in the service or on the client side. And I'll demonstrate how that works by executing some queries and seeing what happens on the client side, server side, and down at the database level. Finally, I'll talk about query validation, which is an ability to decorate your query methods and your API controllers so that the caller cannot execute arbitrarily complex queries. It allows you to put guard conditions on the query method to stop them, for example, from doing an orderby on a column that does not have a database index. And we'll see a quick demo of that as well.
Supporting OData Formatting and Entity Data Models In this module, I'm going to show you how to add support to your Web APIs for OData formatting and using Entity Data Models. You'll see that this unlocks the full capabilities of OData in Web API, allowing you to not only support queryables as we talked about in a previous module, but also letting you return OData formats of several forms that we'll talk about, and the way you do that is by defining Entity Data Models to represent the model that you're exposing on the wire. So first I'm going to talk about the OData formats, and I'll talk about the three formats available, what's involved with each one, and how you go about defining which one you want to use and what they look like at a wire level. Next, I'll talk about Entity Data Models. Entity Data Models form the basis for what you're going to expose from your service in terms of the data structures. This is a little different than what you saw in the querying where you were really just relying on the automatic serialization of whatever data model you had into XML or JSON by Web API. Entity Data Models give the information to serialize your data objects into an OData compatible type system. So we'll talk about what's involved in defining one of those. And there's two different ways to go about it, implicitly and explicitly, and we'll see those as well. Finally, we'll get down to brass tacks and show you how you employ this stuff in your Web APIs. So we'll show you how to define an OData service that supports querying and OData formats.
Updating Web API Resources Through OData In this module, I'm going to show you how you can update your back end resources through OData and your Web API controllers. A lot of the focus so far has been on querying and that is where a lot of the power of OData comes in, is the query syntax that allows callers to execute arbitrary queries against your back end. But just like the standardization that the query syntax and the ATOM format providers for querying, you probably want to be able to update those data resources through a standardized mechanism as well. So part of the OData spec includes being able to update your backend stores. First I'm going to talk about exposing update operations from your EntitySetControllers, and this includes the CUD part of CRUD, Create, Update, and Delete. And you'll see there's some variance on top of Update as well that you have as options. Then I'll talk about returning OData compliant errors. In an earlier module, I talked about HTTP status codes and how they tie into some of the RESTful concepts, and you're still going to be doing that from your OData controllers because they are RESTful themselves, but part of the OData spec is specifying what should go in the payload of the returned responses that correspond to errors on the back end. So there's some structure information that you can put in the payload, and we'll take a look at that. Next, we'll talk about updating relations through OData, and by relations I mean links between resources. So you may need to update those relations separate from updating individual properties of your resources, and there's syntax and OData that supports this. Finally, we'll talk about exposing OData actions, which are additional methods that you can expose from your controllers to take logical actions on the resources that controller represents. In addition to that, we'll talk about handling unhandled requests in your controllers, basically things that don't map to one of your other methods, for debugging and diagnostic purposes primarily.