1

给定一个使用OData 4的Web Api 2.2项目,我正在使用来自第三个共享程序集的实体,我想专门为 api 配置一些实体。

例如:其中一个共享实体SharedEntityA包含一个字段BinaryValue我不想成为navigablesortablefilterable等。

问题是我无法更改共享程序集,因此我无法为其使用属性,例如:

[Unsortable]
[NonFilterable]
[NotNavigable]
public byte[] BinaryValue { get; set; } 

是否可以使用Fluent Api在我的 api 项目中进行配置?

我正在 App_Start/WebApiConfig.cs 中寻找类似的东西:

private static IEdmModel CreateEdmModel()
{
    ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
    builder.EntitySet<SharedEntityA>();

    // This is not working
    builder.Entity<SharedEntityA>()
        .property(e => e.BinaryValue)
        .IsNotSortable()
        .IsNotFilterable()
        .IsNotNavigable();
}

该示例引发编译错误

PrimitivePropertyConfiguration 不包含 IsNotSortable 的定义

4

0 回答 0