在 OData 中匹配大小写 属性 时出现 AmbiguousMatchException

AmbiguousMatchException while match case property in OData

我有两个名称相同但大小写不同的属性 TitleTITLE

public class Product
{
    [Key]
    public Guid Id { get; set; }
    public string Name { get; set; }
    public decimal Price { get; set; }
    public string Category { get; set; }

    [NotMapped]
    public virtual string Title { get; set; }

    public string TITLE { get; set; }
}

我在 OData 配置中包含标题:

ODataModelBuilder builder = new ODataConventionModelBuilder();
        builder.EntitySet<Product>("Products");
        builder.EntityType<Product>().Property(a => a.Title);
        config.MapODataServiceRoute(
        routeName: "ODataRoute",
        routePrefix: null,
        model: builder.GetEdmModel());

这是 OData 控制器的操作:

  public IHttpActionResult Get(ODataQueryOptions<Product> queryOptions, CancellationToken cancellationToken)
  {
     Context = GetContext();
     var products = Context.GetEntities<Product>();
     var result = queryOptions.ApplyTo(products);
     return Ok(result);
  }

当我发送 https://localhost:44326/Products?$select=Id,TITLE 请求时,在 queryOptions.ApplyTo(products); 点我收到以下异常:

System.Reflection.AmbiguousMatchException: 'Ambiguous match found.'

我想使用 $select 获得 Title 和 TITLE 属性。有谁知道如何解决这个问题?

这是 OData 的问题。此问题将在 7.3 版本中修复。这是拉取请求: https://github.com/OData/WebApi/pull/1907