Supercharging your Web APIs with OData and ASP.NET Core
Why Stack Overflow recommends it
Stack Overflow users link it as a reference when explaining or debugging how to enable OData query options like $filter, $select and $expand on a .NET Web API.
Recommended by 1 people across 1 different months, 2018 to 2019.
What it is
A Microsoft Developer episode in which Hassan Habib shows host Jeremy how to add OData support to an existing ASP.NET Core Web API. It covers what OData is, a demo, and enabling shaping, ordering, expanding related entities and filtering of results.
What people said
Recommends ElasticCode · 2019-03 · Stack Overflow · on “How to apply ODataQueryOptions for DTO to underlying EntitySet?”
First Install the OData packages to your Web API project Install-Package Microsoft.AspNet.OData -Version 7.1.0 Configure the OData endpoint in WebApiConfig.cs by Add the following using statements using System.Web.OData.Builder; using System.Web.OData.Extensions; And following code to the Register method public static void Register(HttpConfiguration config) { config.MapHttpAttributeRoutes(); // New code start ODataModelBuilder builder = new ODataConventionModelBuilder(); builder.EntitySet<Foo>("Foos"); builder.EntitySet<Bar>("Bars"); config.MapODataServiceRoute( routeName: "ODataRoute", routePrefix: null, model: builder.GetEdmModel()); config.Count().Filter().OrderBy().Expand().Select().MaxT
Cites anomepani · 2018-07 · Stack Overflow · on “OData vs GraphQL”
I have researched and also tried with Both GraphQL in Dot Net and Odata in DotNet Web API to create a working demo and What I found are Developer Usability Considering you have existing WebAPI(DotNet Framework) and want to migrate to GraphQL or OData compatible WebAPI then my answer is to choose OData because of its easy integration and Out of the Box Filter, OrderBy, Select, Expand, etc feature (Refer MSFT On DotNet OData [this video] ). If you choose GraphQL then you have to do a lot of work like Create Type, Schema and Query and Implement Resolver for each query. Performance depends on your query logic. GraphQL and Odata Both have the capability to get what you request using $select in OData a
Cites Danil Ishutin · 2019-09 · Stack Overflow · on “How to fix Odata with C# WebAPI .NET Core Entity Framework”
I can retrieve all of the data but looks like OData is not working I'm using EFCore Entity Framework Web API. This is my reference for OData [this video] Updated Model below Return should be [ { "name":"FakeHelmet" }, { "name":"OriginalHelmet" }, { "name":"ClassAHelmet" } ] This is my Code. Controller : [HttpGet] [EnableQuery] public async Task<IActionResult> Get() { var models = await service.Filter(); return Ok(models); } Service public async Task<IEnumerable<HelmetDto>> Filter() { var models = repo.GetQueryableTest<Helmet>(); return models.Select(x => SimpleMapper.Map(x, new HelmetDto())); } Repository public virtual IQueryable<TEntity> GetQueryableTest<TEntity>() where TEntity : class, IEntit