繁体   English   中英

odata自定义函数参数的短数据类型(Edm.Int16)

[英]short data type (Edm.Int16) for odata custom function parameter

我在我的EdmModel中声明了一个自定义函数:

var getWebMenu = builder.Function("GetWebMenu");
getWebMenu.Parameter<Guid>("SiteId");
getWebMenu.Parameter<Guid>("LanguageId");
getWebMenu.Parameter<string>("MenuName");
getWebMenu.Parameter<int>("MenuIndex");

当我通过HTTP调用它时,它就可以正常工作。 但是,MenuInde​​x的基础数据类型是shortint16 ),当我将代码转换回short

getWebMenu.Parameter<short>("MenuIndex");

(并且很明显,这会改变我的代码)HTTP调用失败并显示404.0 - Not found

在两种情况下,HTTP调用均如下所示:

http://localhost:19215/GetWebMenu(SiteId=ac2453bd-f2dd-e411-8159-984be10349a2,
    LanguageId=ac2453bd-f2dd-e411-8159-984be10349a2,
    MenuName='Main Menu',MenuIndex=0)?$expand=webMenuItems

当将param声明为short时, http://localhost:19215/$metadata看起来很好:

<Function Name="GetWebMenu">
    <Parameter Name="SiteId" Type="Edm.Guid" Nullable="false"/>
    <Parameter Name="LanguageId" Type="Edm.Guid" Nullable="false"/>
    <Parameter Name="MenuName" Type="Edm.String" Unicode="false"/>
    <Parameter Name="MenuIndex" Type="Edm.Int16" Nullable="false"/>
    <ReturnType Type="data.models.WebMenu"/>
</Function>

更多信息

在写这个问题时,我仔细检查了几件事,并且发现我对代码中的更改进行“明显”流动的假设似乎使我至少感到不满意。 失败时,Controller函数签名如下所示:

[ODataRoute("GetWebMenu(SiteId={siteId}, LanguageId={languageId}, MenuName={menuName},
    MenuIndex={menuIndex})")]
[SingleResultEnableQuery]
public SingleResult<WebMenu> GetWebMenu([FromODataUri] Guid siteId, 
    [FromODataUri] Guid languageId, [FromODataUri] string menuName, 
    [FromODataUri] short menuIndex) 

查看menuIndexshort数据类型? 当我更改getWebMenu.Parameter<short>("MenuIndex");时,我将其更改为int getWebMenu.Parameter<short>("MenuIndex"); 数据类型为int ,反之亦然。

回答? 然而; 如果我保留getWebMenu.Parameter<int>("MenuIndex"); 作为一个int并将其余代码保持short ,HTTP调用就可以正常工作。

题! 由于Edm.Int16是支持的类型,我希望我的用户知道的Edm.Int16是必需的,请能有人告诉我,我该怎么申报short于上EdmModel我的自定义函数的声明?

我们的工程师已将其确认为ODataLib中URL解析器中的错误,并为此创建了一个GitHub问题: https : //github.com/OData/odata.net/issues/154 请使用它监视修复状态。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM