AspNetCoreOData
AspNetCoreOData copied to clipboard
OData-EnableQuery query params filter, select, top prevents the step-by-step processing of IEnumerable and the complete ODataController handle IEnumerable results without enumeration/streaming the output data
.NET6 & OData 8.0.8 If a controller returns an IEnumerable as result, this is requested completely. This was partially correct in .NET Core 3.1. Especially with the parameter $top this has always been broken.
public class ApiStreamTestController : ControllerBase
{...
[HttpGet]
[EnableQuery]
public IEnumerable<StreamTestModel> Get(){ foreach (var row in StreamTestModelData.DataCache) yield return row; }
}...
public class StreamTestController : ODataController
{
[HttpGet]
[EnableQuery]
public IEnumerable<StreamTestModel> Get(){ foreach (var row in StreamTestModelData.DataCache) yield return row; }
...}
Here the complete foreach is queried if OData parameters are used.
The complete code with the test is attached StreamTest.NET6.zip
Summary: ODataController
- ODataStreamingTest_Raw_are_not_supported
- ODataStreamingTest_Filter_And_Select_are_not_supported
- ODataStreamingTest_Top_is_not_supported
- ODataStreamingTest_OrderBy_cannot_work (it's ok)
ControllerBase
- StreamingTest_Raw_are_supported
- StreamingTest_Filter_And_Select_are_not_supported
- StreamingTest_Top_is_not_supported
- StreamingTest_OrderBy_cannot_work (it's ok)
@gathogojr @corranrogue9 Are there any findings now ? 22.06.2022