kodebot
kodebot

Reputation: 1778

BreezeJS - Is there any way to use old style 'One controller to rule them all' with OData Web API?

I would like to expose the SQL Server Views via OData Web API but I don't want to create separate controllers for each views as there are too many of them and they will only accept GET verb for all the views.

I thought I can achieve this using BreezeController but it looks like I cannot as it is obsolete now (The package which has BreezeController attribute is marked as obsolete).

Is there any way to achieve this with OData Web API that works with BreezeJS?

Upvotes: 0

Views: 65

Answers (1)

Ward
Ward

Reputation: 17863

The [BreezeController] attribute is not obsolete. In fact, it is central to the "happy path" Web API controllers you see in the Breeze samples. I wonder what lead you to think otherwise? What package are you using?

I'm referring to the ASP.NET Web API!

The ASP.NET Web API OData is a different matter. Despite "Web API" in the name, that is almost a completely different approach to server development with its own behaviors and wire format. It does not use the [BreezeController] attribute and never has.

I'm not sure what you meant by "view" in your phrase, "separate controllers for each view". I think you mean what I would call "type". For example, in OData you'd expect a "Product" endpoint for your Product entity type.

AFAIK, the Web API OData approach demands a separate controller per type. That's what Microsoft's Mike Wasson says in his tutorial. He writes ...

A controller is a class that handles HTTP requests. You create a separate controller for each entity set in your OData service.

BreezeJS supports Web API OData too ... although there are limitations imposed by the current Microsoft implementation that may give you pause.

We are working through these with the OData team and hope to have better news in the coming months.

Upvotes: 2

Related Questions