RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

DEvx blogs image

Designing Better Web APIs with Breeze Server

Posted by Sandeep Chanda on May 26, 2014


Breeze.js is a fairly popular JavaScript library (in quite a long list) that helps you manage business data objects from rich JS client applications. The origins of the library first surfaced during the Silverlight days where it gained popularity in seamless integration with LINQ. Since the creators come from the .NET background, Breeze.js suitably provided a server side, where it enhanced the capabilities of HTTP services in the form of Web API.

The ASP.NET Web API is very powerful in creating HTTP Services. While using Web API you have two approaches for creating HTTP Services. The first approach is creating controllers for each Entity having four methods representing the CRUD operations using the HTTP verbs. This follows the RESTFul approach. Another option is to use OData services that allow clients to create their own queries and use Web API to execute them on the data store.

If you are building services using Web API which are idiosyncratic in nature, then you need to provide outside-the-band metadata information to your consumers about your API design. This is where Breeze Server can be very useful. You can use Breeze to design robust APIs and Breeze will create and expose metadata for your controller.

Install Breeze

To use Breeze Server, you need to use a couple of nuget packages as shown in the screen print below:

This is assuming that you will use Entity Framework as your data access layer. Alternatively you can also use it with NHibernate.

Configure Breeze

Now that you have installed Breeze, you can start configuring your Controller and API methods with Breeze. For every controller, you can use the BreezeController attribute to indicate a Breeze Controller class. Breeze also provides the EFContextProvider class that encapsulates EF DbContext into controlling the CRUD operation behaviour and providing the metadata for the operations.

In the next blog post we will see how the Web API controllers are manipulated by a Breeze Server implementation and explore its true power.


Web services, JavaScript libraries, Web API

Recent Entries

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date