在 Net Core 3.1 和 oData 7.5.0 中
[HttpGet]
[EnableQuery]
[Route("categories/{categoryId}/elements")]
[ODataRoute("categories/{categoryId}/elements")]
public Task<IQueryable<CategoryElement>> QueryActiveElementsByCategoryIdAsync(int categoryId)
{
return this.processor.QueryAllAsync<CategoryElement>(c => c.CategoryId == categoryId && c.IsActive == true);
}
在 Net 6 和 oData 8.1.1 中
[HttpGet("categories/{categoryId}/elements")]
[EnableQuery]
[TrueAuthorize(Role.Administrator)]
public Task<IQueryable<CategoryElement>> QueryActiveElementsByCategoryIdAsync(int categoryId)
{
return this.processor.QueryAllAsync<CategoryElement>(c => c.CategoryId == categoryId && c.IsActive == true);
}
因此预期结果与Front不兼容