Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ODataConventionModelBuilder usage

Apart from auto mapping CLR Classes to EDM models, what are the advantages or use-cases for the ODataConventionModelBuilder ?

What specific set of pains does it make go away? With sample code if possible.

like image 202
GilliVilla Avatar asked Aug 29 '13 21:08

GilliVilla


People also ask

What is ODataConventionModelBuilder?

ODataConventionModelBuilder is used to automatically map CLR classes to an EDM model based on a set of.

What is OData EDM?

OData service uses an abstract data model called Entity Data Model (EDM) to describe the exposed data in the service. OData client can issue a GET request to the root URL of the OData service with $metadata to get an XML representation of the service's data model. In Microsoft ASP.NET Web API 2.2 for OData v4.

What is Odataqueryoptions?

OData defines parameters that can be used to modify an OData query. The client sends these parameters in the query string of the request URI. For example, to sort the results, a client uses the $orderby parameter: http://localhost/Products?$orderby=Name. The OData specification calls these parameters query options.

What is OData in Web API?

The Open Data Protocol (OData) is a data access protocol for the web. OData provides a uniform way to query and manipulate data sets through CRUD operations (create, read, update, and delete). ASP.NET Web API supports both v3 and v4 of the protocol.


1 Answers

ODataConventionModelBuilder is used for generating the Entity Data Model (EDM) for your OData service. The main purpose of EDM is used to define the type system, relationships and the actions that can be exposed by your OData service model.

If you are looking for a specific example, see this link - http://bitoftech.net/2014/04/16/create-read-only-odata-endpoint-using-asp-net-web-api/

In general OdataConventionModelBuilder is preferred over ODataModelBuilder since it infers the inheritance hierarchies, navigation properties and standard properties.

Also look at this link - http://blogs.msdn.com/b/alexj/archive/2012/11/02/odata-in-webapi-microsoft-asp-net-web-api-odata-0-2-0-alpha-release.aspx

like image 151
Venki Avatar answered Oct 14 '22 00:10

Venki