Search code examples
entity-frameworkasp.net-web-apiodata

Web API OData with Stored Procedures


Can I leverage the power of OData without EF?

I'm using an existing DB and creating my models using stored procedures to retrieve from DB.

AFAIK, when using $filter for example using OData with EF - the filter will be applied at the DB layer.

The way it works now is that all results are brought back from the DB and only then the filter is applied.

Since the processing time and server load are gone to waste this way, I'd like to know how I can customize it so that only the results that I need will get returned.

Maybe it would be easier to work with EF?

The DB is pretty complex - most model objects are built from many different tables using joins.


Solution

  • You can use Entity Framework to import your stored procedures and then use the entities based on those stored procs with the Web API OData ODataController / EntitySetController.