Web API 2核心中的WebApiConfig在哪里?

时间:2017-07-31 19:27:29

标签: c# .net asp.net-core asp.net-web-api2 owin

我在this教程之后尝试公开静态集合的odata端点。

应该在哪里配置?

public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        config.MapODataServiceRoute("odata", null, GetEdmModel(), new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));
        config.EnsureInitialized();
    }
    private static IEdmModel GetEdmModel()
    {
        ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
        builder.Namespace = "Demos";
        builder.ContainerName = "DefaultContainer";
        builder.EntitySet<Person>("People");
        builder.EntitySet<Trip>("Trips");
        var edmModel = builder.GetEdmModel();
        return edmModel;
    }
}

这是目前的结构:

enter image description here

我在哪里可以配置MapOdataEndPoint并创建模型构建器?

0 个答案:

没有答案