gpt4 book ai didi

c# - Web API OData EnableLowerCamelCase

转载 作者:太空狗 更新时间:2023-10-29 22:58:33 26 4
gpt4 key购买 nike

我有一个使用 OData 的 Web API 2 应用程序,我需要在序列化时以小驼峰形式公开模型属性。

有一个EnableLowerCamelCase似乎是这样做的方法,但我无法让它被编译器识别。 CodePlex 上什至有一个使用 OData 6.5.0 的示例 that shows EnableLowerCamelCase .

ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EnableLowerCamelCase(); // <-- this won't compile

是否已删除 EnableLowerCamelCase?我错过了什么?

我正在使用以下软件包版本:

<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
<package id="elmah" version="1.2.2" targetFramework="net45" />
<package id="elmah.corelibrary" version="1.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.OData" version="5.3.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.0" targetFramework="net45" />
<package id="Microsoft.OData.Core" version="6.8.0" targetFramework="net45" />
<package id="Microsoft.OData.Edm" version="6.8.0" targetFramework="net45" />
<package id="Microsoft.Spatial" version="6.8.0" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net45" />
</packages>

最佳答案

简单的改变

ODataModelBuilder builder = new ODataConventionModelBuilder();

ODataConventionModelBuilder builder = new ODataConventionModelBuilder();

var builder = new ODataConventionModelBuilder();

它应该可以编译。我使用最新的 ASP.NET Web API 2.2 for OData v4.0 (v5.3.1) 对其进行了测试。

关于c# - Web API OData EnableLowerCamelCase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27365570/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com