All Projects → suadev → aspnet-core-web-api-using-odata

suadev / aspnet-core-web-api-using-odata

Licence: other
Demo application of my speech 'Add OData Support to Your Asp.Net Core Web Api' at Dotnet Konf İstanbul. http://dotnetkonf.com/

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to aspnet-core-web-api-using-odata

Beef
Business Entity Execution Framework
Stars: ✭ 95 (+239.29%)
Mutual labels:  dotnetcore, webapi, odata
Fasthttpapi
a lightweight and high-performance http/websocket service component in the dotnet core platform that supports TLS.
Stars: ✭ 554 (+1878.57%)
Mutual labels:  dotnetcore, webapi
FSharpNetCoreWebApiTemplate
F# .net core web api template
Stars: ✭ 17 (-39.29%)
Mutual labels:  dotnetcore, webapi
Weapsy
ASP.NET Core CMS
Stars: ✭ 748 (+2571.43%)
Mutual labels:  dotnetcore, webapi
Awesome Cms Core
Awesome CMS Core is an open source CMS built using ASP.Net Core & ReactJS with module seperation concern in mind and provide lastest trend of technology like .Net Core, React, Webpack, SASS, Background Job, Message Queue.
Stars: ✭ 352 (+1157.14%)
Mutual labels:  dotnetcore, webapi
Aspnet Api Versioning
Provides a set of libraries which add service API versioning to ASP.NET Web API, OData with ASP.NET Web API, and ASP.NET Core.
Stars: ✭ 2,154 (+7592.86%)
Mutual labels:  webapi, odata
Beetle.js
🪲 Javascript ORM, manage your data easily.
Stars: ✭ 53 (+89.29%)
Mutual labels:  webapi, odata
Urf.core
Unit of Work & Repositories Framework - .NET Core, NET Standard, Entity Framework Core. 100% extensible & lightweight. Live demo: https://goo.gl/QpJVgd
Stars: ✭ 226 (+707.14%)
Mutual labels:  dotnetcore, webapi
Dotnetlabs
.NET Labs -- Show Me the Tips and Tricks and Code
Stars: ✭ 135 (+382.14%)
Mutual labels:  dotnetcore, webapi
Event Sourcing Castanha
An Event Sourcing service template with DDD, TDD and SOLID. It has High Cohesion and Loose Coupling, it's a good start for your next Microservice application.
Stars: ✭ 68 (+142.86%)
Mutual labels:  dotnetcore, webapi
Furion
Make .NET development easier, more versatile, and more popular.
Stars: ✭ 902 (+3121.43%)
Mutual labels:  dotnetcore, webapi
GPONMonitor
GPON Monitoring tool for Dasan Networks GPON OLTs
Stars: ✭ 26 (-7.14%)
Mutual labels:  dotnetcore, webapi
rabbitmq-labs
The source code for my RabbitMQ tutorials.
Stars: ✭ 45 (+60.71%)
Mutual labels:  dotnetcore, webapi
aspnet-api-versioning
Provides a set of libraries which add service API versioning to ASP.NET Web API, OData with ASP.NET Web API, and ASP.NET Core.
Stars: ✭ 2,396 (+8457.14%)
Mutual labels:  webapi, odata
Learning.EventStore
A framework for CQRS, Eventsourcing, and messaging that uses Redis pub/sub for messaging and offers event persistence in Redis, SQL Server, or PostgreSQL.
Stars: ✭ 58 (+107.14%)
Mutual labels:  dotnetcore
RRQMSocket
TouchSocket是.Net(包括 C# 、VB.Net、F#)的一个整合性的、超轻量级的网络通信框架。包含了 tcp、udp、ssl、http、websocket、rpc、jsonrpc、webapi、xmlrpc等一系列的通信模块。一键式解决 TCP 黏分包问题,udp大数据包分片组合问题等。使用协议模板,可快速实现「固定包头」、「固定长度」、「区间字符」等一系列的数据报文解析。
Stars: ✭ 286 (+921.43%)
Mutual labels:  webapi
MASA.Blazor
Blazor component library based on Material Design. Support Blazor Server and Blazor WebAssembly.
Stars: ✭ 469 (+1575%)
Mutual labels:  dotnetcore
MvcControlsToolkit.Core
Core Code for MvcControlsToolkit packages
Stars: ✭ 13 (-53.57%)
Mutual labels:  dotnetcore
TraceHub
Centralized and distributed logging for Web applications and services, extending System.Diagnostics and Essential.Diagnostics, providing structured tracing and logging withou needing to change 1 line of your application codes
Stars: ✭ 22 (-21.43%)
Mutual labels:  webapi
open-pdd-net-sdk
拼多多开放平台DotNet SDK
Stars: ✭ 133 (+375%)
Mutual labels:  dotnetcore

Presentation : https://speakerdeck.com/suadev/add-odata-support-to-asp-dot-net-core-web-api

This repo aims to show that how easily OData can be added to your existing/new Asp.Net Core Web Api to perform all CRUD operations.

This is a simple api that consist of two entities called Product and ProductCategory.

localhost:5000/api/products -> classic rest endpoint

localhost:5000/odata/products -> odata rest endpoint

You can check following sample OData queries and results.

if you like Postman, just import AspNetCore_OData.postman_collection.json file and you will see more sample query in Get folders.

Get All Categories - http://localhost:5000/odata/product_categories?$count=true

{
    "@odata.context": "http://localhost:5000/odata/$metadata#product_categories",
    "@odata.count": 3,
    "value": [
        {
            "id": "1236a458-0802-4340-bdd4-05859c9aaaad",
            "categoryName": "Headphones"
        },
        {
            "id": "8b726886-e719-413c-a125-939ee5af387d",
            "categoryName": "TV"
        },
        {
            "id": "a65bc1ae-c1c7-4c20-8b3b-4b48490d3fb0",
            "categoryName": "Computers"
        }
    ]
}

Get All Products - http://localhost:5000/odata/products?$count=true

 {
    "@odata.context": "http://localhost:5000/odata/$metadata#products",
    "@odata.count": 3,
    "value": [
        {
            "id": "6d42ac79-2b65-460d-9991-22b86ad66fb9",
            "productName": "JBL Tune",
            "categoryId": "1236a458-0802-4340-bdd4-05859c9aaaad",
            "description": "JBL Tune 500BT On-Ear",
            "price": 15,
            "weight": 0.3
        },
        {
            "id": "78a4a7db-073f-4ad9-a157-2a9da0ceae38",
            "productName": "HP Zbook",
            "categoryId": "a65bc1ae-c1c7-4c20-8b3b-4b48490d3fb0",
            "description": "HP Zbook Laptop",
            "price": 2000,
            "weight": 3
        },
        {
            "id": "aec7ce71-bfa6-4b0f-8aef-78816a31c9fa",
            "productName": "LG 32-Inch",
            "categoryId": "8b726886-e719-413c-a125-939ee5af387d",
            "description": "LG 32-Inch 720p LED TV",
            "price": 12000,
            "weight": 60
        }
    ]
}

Get Product by ID - http://localhost:5000/odata/products(010b34c3-5d91-4f15-a926-a4edbc3a9770)

{
    "@odata.context": "http://localhost:5000/odata/$metadata#products/$entity",
    "id": "6d42ac79-2b65-460d-9991-22b86ad66fb9",
    "productName": "JBL Tune",
    "categoryId": "1236a458-0802-4340-bdd4-05859c9aaaad",
    "description": "JBL Tune 500BT On-Ear",
    "price": 15,
    "weight": 0.3
}

Filter by Price (price greater than 10000) - http://localhost:5000/odata/products?$filter=price%20gt%2010000

{
    "@odata.context": "http://localhost:5000/odata/$metadata#products",
    "value": [
        {
            "id": "aec7ce71-bfa6-4b0f-8aef-78816a31c9fa",
            "productName": "LG 32-Inch",
            "categoryId": "8b726886-e719-413c-a125-939ee5af387d",
            "description": "LG 32-Inch 720p LED TV",
            "price": 12000,
            "weight": 60
        }
    ]
}

Order by Price - http://localhost:5000/odata/products?$orderby=price

{
    "@odata.context": "http://localhost:5000/odata/$metadata#products",
    "value": [
        {
            "id": "6d42ac79-2b65-460d-9991-22b86ad66fb9",
            "productName": "JBL Tune",
            "categoryId": "1236a458-0802-4340-bdd4-05859c9aaaad",
            "description": "JBL Tune 500BT On-Ear",
            "price": 15,
            "weight": 0.3
        },
        {
            "id": "78a4a7db-073f-4ad9-a157-2a9da0ceae38",
            "productName": "HP Zbook",
            "categoryId": "a65bc1ae-c1c7-4c20-8b3b-4b48490d3fb0",
            "description": "HP Zbook Laptop",
            "price": 2000,
            "weight": 3
        },
        {
            "id": "aec7ce71-bfa6-4b0f-8aef-78816a31c9fa",
            "productName": "LG 32-Inch",
            "categoryId": "8b726886-e719-413c-a125-939ee5af387d",
            "description": "LG 32-Inch 720p LED TV",
            "price": 12000,
            "weight": 60
        }
    ]
}

Skip & Take - http://localhost:5000/odata/products?$count=true&$top=2&$skip=1

{
    "@odata.context": "http://localhost:5000/odata/$metadata#products",
    "@odata.count": 3,
    "value": [
        {
            "id": "78a4a7db-073f-4ad9-a157-2a9da0ceae38",
            "productName": "HP Zbook",
            "categoryId": "a65bc1ae-c1c7-4c20-8b3b-4b48490d3fb0",
            "description": "HP Zbook Laptop",
            "price": 2000,
            "weight": 3
        },
        {
            "id": "aec7ce71-bfa6-4b0f-8aef-78816a31c9fa",
            "productName": "LG 32-Inch",
            "categoryId": "8b726886-e719-413c-a125-939ee5af387d",
            "description": "LG 32-Inch 720p LED TV",
            "price": 12000,
            "weight": 60
        }
    ]
}

Get Product Count - http://localhost:5000/odata/products?$top=0&$count=true

{
    "@odata.context": "http://localhost:5000/odata/$metadata#products",
    "@odata.count": 3,
    "value": []
}

Select Specific Fields - http://localhost:5000/odata/products?$select=id,productname

{
    "@odata.context": "http://localhost:5000/odata/$metadata#products(id,productName)",
    "value": [
        {
            "id": "6d42ac79-2b65-460d-9991-22b86ad66fb9",
            "productName": "JBL Tune"
        },
        {
            "id": "78a4a7db-073f-4ad9-a157-2a9da0ceae38",
            "productName": "HP Zbook"
        },
        {
            "id": "aec7ce71-bfa6-4b0f-8aef-78816a31c9fa",
            "productName": "LG 32-Inch"
        }
    ]
}

Expand with CategoryGroup - http://localhost:5000/odata/products?$expand=category

{
    "@odata.context": "http://localhost:5000/odata/$metadata#products",
    "value": [
        {
            "id": "6d42ac79-2b65-460d-9991-22b86ad66fb9",
            "productName": "JBL Tune",
            "categoryId": "1236a458-0802-4340-bdd4-05859c9aaaad",
            "description": "JBL Tune 500BT On-Ear",
            "price": 15,
            "weight": 0.3,
            "category": {
                "id": "1236a458-0802-4340-bdd4-05859c9aaaad",
                "categoryName": "Headphones"
            }
        },
        {
            "id": "78a4a7db-073f-4ad9-a157-2a9da0ceae38",
            "productName": "HP Zbook",
            "categoryId": "a65bc1ae-c1c7-4c20-8b3b-4b48490d3fb0",
            "description": "HP Zbook Laptop",
            "price": 2000,
            "weight": 3,
            "category": {
                "id": "a65bc1ae-c1c7-4c20-8b3b-4b48490d3fb0",
                "categoryName": "Computers"
            }
        },
        {
            "id": "aec7ce71-bfa6-4b0f-8aef-78816a31c9fa",
            "productName": "LG 32-Inch",
            "categoryId": "8b726886-e719-413c-a125-939ee5af387d",
            "description": "LG 32-Inch 720p LED TV",
            "price": 12000,
            "weight": 60,
            "category": {
                "id": "8b726886-e719-413c-a125-939ee5af387d",
                "categoryName": "TV"
            }
        }
    ]
}

Expand with CategoryGroup and Select - http://localhost:5000/odata/products?$expand=category($select=categoryName)&$select=id,productName

{
    "@odata.context": "http://localhost:5000/odata/$metadata#products(id,productName,category(categoryName))",
    "value": [
        {
            "id": "6d42ac79-2b65-460d-9991-22b86ad66fb9",
            "productName": "JBL Tune",
            "category": {
                "categoryName": "Headphones"
            }
        },
        {
            "id": "78a4a7db-073f-4ad9-a157-2a9da0ceae38",
            "productName": "HP Zbook",
            "category": {
                "categoryName": "Computers"
            }
        },
        {
            "id": "aec7ce71-bfa6-4b0f-8aef-78816a31c9fa",
            "productName": "LG 32-Inch",
            "category": {
                "categoryName": "TV"
            }
        }
    ]
}

Running Locally

  • docker-comppose up (for postgres instance)
  • dotnet run

Migration

  • dotnet ef migrations add "init" -c ProductDbContext -p src/OData.WebApi --output-dir Data/Migrations
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].