ASP.NET 5에 OData를 등록하는 방법 (How to register OData with ASP.NET 5)


문제 설명

ASP.NET 5에 OData를 등록하는 방법 (How to register OData with ASP.NET 5)

ASP.NET 5 응용 프로그램이 있고 이 응용 프로그램과 함께 OData v4를 사용하고 싶습니다.

여기에 내가 시도한 것이 있습니다.

1.다음 nuget을 가져왔습니다. 패키지:

"Microsoft.AspNet.WebApi": "5.2.3",
"Microsoft.AspNet.OData": "5.7.0",
"Microsoft.AspNet.Hosting": "1.0.0‑rc1‑final"

2.Startup.Configure 메서드에서 호출

GlobalConfiguration.Configure(ConfigOData);

3.마지막으로 OData 구성입니다.

private static void ConfigOData(HttpConfiguration config)
{
    ODataConventionModelBuilder builder = new ODataConventionModelBuilder();

    var EDM = builder.GetEdmModel();

    //OData v4.0
    config.MapODataServiceRoute("odata", "odata", EDM,
        new DefaultODataPathHandler(),
        conventions,
        new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));
}

이제 OData 호출이 MVC의 라우팅 구성에 의해 처리되고 있습니다(아마도 ASP.NET 5에 OData를 제대로 등록하지 않았기 때문일 수 있습니다).

누군가 나를 도와줄 수 있습니까?


참조 솔루션

방법 1:

Here is how we can configure it with the ASP.NET Core RC2 OData.

namespace ODataSample
{
    using Microsoft.AspNetCore.OData.Extensions;
    using Microsoft.AspNetCore.Builder;
    using Microsoft.Extensions.DependencyInjection;
    using ODataSample.Models;

    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddOData<ISampleService>();
        }

        public void Configure(IApplicationBuilder app)
        {
            app.UseOData("odata");
            app.UseMvc();
        }
    }
}

Here is how you can try it yourself. You will need to have the .NET Core SDK installed.

git clone git@github.com:bigfont/WebApi.git

cd WebApi\vNext\src\Microsoft.AspNetCore.OData
dotnet restore

cd ..\..\samples\ODataSample.BigFont\
dotnet restore
dotnet run

This is the result at http://localhost:5000/odata

Result

Links

(by AymanShaun Luttin)

참조 문서

  1. How to register OData with ASP.NET 5 (CC BY‑SA 2.5/3.0/4.0)

#asp.net-core #odata






관련 질문

ASP.NET 5 프로젝트용 DNX를 선택하는 방법 (How to choose DNX for ASP.NET 5 project)

ASP.NET 5 - 프로젝트의 파일 참조(csproj와 유사한 참조 누락) (ASP.NET 5 - Referencing files in projects (missing csproj-like references))

ASP.NET 5에 OData를 등록하는 방법 (How to register OData with ASP.NET 5)

Asp.net 5 - 도커 (Asp.net 5 - Docker)

ASP.NET Core MVC에서 컨트롤러별로 데이터베이스에서 정보 읽기 (Reading information from database by controller in ASP.NET Core MVC)

이 목록에 정렬 오류가 있는 이유는 무엇입니까? (Why is there a sorting error in this list?)

foreach 루프에서 모든 데이터를 반환하는 방법 (How to return all data in foreach loop)

읽기 전용 면도기 C# asp.net의 드롭다운 목록을 만드는 방법 (how to make dropdownlistfor readonly razor c# asp.net)

.net Core: C# 코드에서 매개 변수를 전달하고 Azure 데이터 팩터리 파이프라인을 실행하는 방법은 무엇입니까? (.net Core : How to pass parameters and run Azure data factory pipeline from C# Code?)

현재 .NET SDK는 TFS 2015 빌드에서 .NET Core 3.0 대상 지정을 지원하지 않습니다. (The current .NET SDK does not support targeting .NET Core 3.0 on TFS 2015 build)

HTTP 오류 500.30 - ANCM 진행 중인 시작 실패 Asp.net-Core 3.1 (HTTP Error 500.30 - ANCM In-Process Start Failure Asp.net-Core 3.1)

System.Data.SqlClient.TdsParser' 예외가 발생했습니다: System.BadImageFormatException: 잘못된 형식의 프로그램을 로드하려고 했습니다. (System.Data.SqlClient.TdsParser' threw an exception: System.BadImageFormatException: An attempt was made to load a program with an incorrect format)







코멘트