OData / OData/AspNetCoreOData

8.0.3 Broke Expand

Open
#330 7 comments 0 reactions 1 assignee View on GitHub

@xuzhg is already working on this.

Since Oct 12, 2021.

Fixed followup
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

I am using this library in a custom project but not with the odatacontrollers, but a custom endpoint implementation instead.

                var context = new ODataQueryContext(manager.Model, type, new Microsoft.OData.UriParser.ODataPath());
                IODataFeature odataFeature = request.HttpContext.ODataFeature();
                odataFeature.RoutePrefix =  "/api/";
              
                context.DefaultQuerySettings.EnableFilter = true;
                context.DefaultQuerySettings.EnableExpand = true;
                context.DefaultQuerySettings.EnableSelect = true;
                context.DefaultQuerySettings.EnableCount = true;
                context.DefaultQuerySettings.EnableSkipToken = true;

                var odata = new ODataQueryOptions(context, request);
              
                metadataQuerySet = odata.ApplyTo(metadataQuerySet);

Basically doing the above stuff to apply odata filtering on my IQueryable data source dynamically.

This broke with $expand on 8.0.3 from 8.0.2

In 8.0.2, https://github.com/OData/AspNetCoreOData/blob/8.0.2/src/Microsoft.AspNetCore.OData/Query/Query/SelectExpandQueryOption.cs#L366 is used to

 var autoSelectProperties = EdmHelpers.GetAutoSelectProperties(null,
                baseEntityType, model, modelBoundQuerySettings);

image

which allowed the pathStructuredType to be null. I have not figured out if this should be anything other than null or if its null due to my way of using the library.

But in 8.0.3, this was refactored to use https://github.com/OData/AspNetCoreOData/blob/8.0.3/src/Microsoft.AspNetCore.OData/Query/Query/SelectExpandQueryOption.cs#L382
and
https://github.com/OData/AspNetCoreOData/blob/8.0.3/src/Microsoft.AspNetCore.OData/Edm/AutoSelectExpandHelper.cs#L148
which throws an exception when this is null

image

I been debugging the two versions, and cant find anything why this breaks my stuff other than the null argument. Could there be an underlaying issue or is it possible to get help doing a new example where we do odata filering out of the core odatacontroller stuff?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.