在ASP.NET中全局设置ODataValidationSettings(例如MaxNodeCount)

时间:2018-05-15 09:47:27

标签: c# asp.net asp.net-web-api odata

有没有办法在ASP.NET Web API中全局设置ODataValidationSettings的属性?

我希望为所有控制器更改MaxNodeCount,并在全局OData配置期间寻找一种方法:

public static void Register(HttpConfiguration config)
{
    var builder = new ODataConventionModelBuilder();

    config.MapODataServiceRoute("odata", "odata", builder.GetEdmModel());

    config
        .Select()
        .Expand()
        .Filter()
        .OrderBy()
        .MaxTop(null)
        .Count()
        // Looking for something like this:
        .MaxNodeCount(20)
        // Or like this:
        .SetDefaultODataValidationSettings(new ODataValidationSettings {MaxNodeCount = 20});
}

0 个答案:

没有答案