Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OData without IQueryable

I’m thinking of using OData for my web service (based on Web API). Unfortunately, my datasource is NOT IQueryable. Instead of implementing my own IQueryable I pretty much followed this blog post.

What I don’t understand is how to get to my entity data model (EDM)? Do I have to model an EDM for example in the Designer? Or is this for EF only and I can use „plain“ classes instead and set relation-attributes? I don’t want to expose my internal data structures therefore my EDM is more like DTOs...

In an example I’ve seen that I‘m supposed to derive from EntitySetController in order to get the OData-compliant HTTP response. I believe I can’t use EntitySetController as I don’t support IQueryable. What am I supposed to do in order to get a proper response anyway?

like image 702
Dunken Avatar asked Oct 04 '22 06:10

Dunken


1 Answers

You can build an EDM model yourself. You can use the ODataConventionModelBuilder class to build your EDM model. This tutorial has some sample code. Also, checkout the samples on OData from here, especially the ODataServiceSample and ODataCompositeKeySample. They should get you started.

Also, if you do not have an IQueryable, you could derive from ODataController instead of EntitySetController.

like image 177
RaghuRam Nadiminti Avatar answered Oct 10 '22 04:10

RaghuRam Nadiminti