Comments (3)
Unfortunately, /People('russellwhyte')?$expand=Friends($select=FirstName)&$select=Friends
is not a valid request because Friends
, being a navigation property, cannot be used in a $select
statement. A workaround could be to either $select
a known value like UserName
, or just directly calling /People('russellwhyte')/Friends
.
from odata.net.
Sorry - I don’t think that’s correct. Your reference TripPin service on data.org accepts it’s just fine and returns a payload respecting the intended projection. Could you please check again. OData V3 client behaves correctly in this regard and issues a select part letting the server know what to return - and that is not everything.
from odata.net.
Hi @corranrogue9
According to the protocol documentation at odata.org navigation properties are perfectly valid in $select. Please check https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#_Toc31361040 where it is stated that:
If the select item is a navigation property, then the corresponding navigation link is represented in the response. If the navigation property also appears in an $expand query option, then it is additionally represented as inline content. This inline content can itself be restricted with a nested $select query option, see section 5.1.2.
The ABNF also states that navigation properties are allowed as select property, please check https://docs.oasis-open.org/odata/odata/v4.01/cs01/abnf/odata-abnf-construction-rules.txt. Where the $select is described as:
select = ( "$select" / "select" ) EQ selectItem *( COMMA selectItem )
selectItem = STAR
/ allOperationsInSchema
/ [ ( qualifiedEntityTypeName / qualifiedComplexTypeName ) "/" ]
( selectProperty
/ qualifiedActionName
/ qualifiedFunctionName
)
selectProperty = primitiveProperty
/ primitiveColProperty [ OPEN selectOptionPC *( SEMI selectOptionPC ) CLOSE ]
/ navigationProperty
/ selectPath [ OPEN selectOption *( SEMI selectOption ) CLOSE
/ "/" selectProperty
]
Also please note that the OData Client for OData V3 did include the navigation property in the $select - correctly letting a V3 service know that it shouldn't return all primitive and complex properties for that specific path when they were not part of the projection. OData V3 client (Microsoft.Data.Services.Client 5.8.5) produces this request for the same query (on V3 the $select is not wrapped inside the $expand):
/People('russellwhyte')?$expand=Friends&$select=Friends/FirstName
On OData V3 client - if we have the expanded Firends navigation property selected projectionless the request will include the navigation property in the $select letting the service know that it should return all propeties from the Friends navigation path, but none of the properties from the root path People('russelwhyte'). So a V3 query like...
var q = from p in ctx.People
where p.UserName == "russellwhyte"
select new Person
{
Friends = p.Friends
};
Will produce a request like:
/People('russellwhyte')?$expand=Friends&$select=Friends/*
As the V3 protocol had all selects sitting on the root level there would be a select on the root path in such situations. The V4 protocol has the select properties nested within the $expand path. This leads to this "bug" where the root path will become projectionless in theses scenarios where the materializer clearly have it projected and all other properties than Friends on the root path is ignored.
If there are other ways to resolve this issue than including the navigation property Friends in the root $select, then that is also fine - as long as we can agree on that we have a performance issue here with queries like this. Our model have rather large entity types (having hundreds of properties) - this issue is really bad for developers doing queries like this - they have all the projections in place minimizing the response payload to only include what they actually need - but the actual payload is wrong as the projection is missing on the root path.
Thanks for looking into this issue
Uffe
from odata.net.
Related Issues (20)
- Nav prop on complex type returned from a collection
- Mitigate ArgumentOutOfRangeException when the typename in context URL is not fully qualified HOT 2
- Querying by primary key throws exception if element doesn't exist HOT 1
- EdmLib successfully parses type names with unbalanced parens HOT 1
- Issue with data conversion errors. HOT 5
- Remove `IContainerProvider` and pass the `IServiceProvider` directly to the message reader or writer HOT 4
- Remove `ODataMessageInfo` from the DI container
- ODL 8 breaking changes tracking
- re: CustomUriFunctions should not be static or irreversible
- Filter on nullable DateOnly seems not supported HOT 2
- Set license expression on nuget packages
- ODataException is thrown when getting a worksheet table rows via Microsoft.Graph API HOT 2
- Exception thrown when trying to create EdmTargetPath from string path that contains type casts HOT 1
- WritesJsonElementCorrectly() test fails Intermittently in the release pipeline HOT 2
- Scale facet value has wrong scaling
- Unhandled Exception: System.TypeInitializationException: The type initializer for 'Microsoft.OData.Edm.Vocabularies.V1.CoreVocabularyModel' threw an exception. ---> System.BadImageFormatException: Could not load file or assembly 'System.Reflection, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058) ---> System.BadImageFormatException: Cannot load a reference assembly for execution.
- NullReference exception generated when using FilterClause.ApplyTo method with open properties in the filter query
- Python library to convert existing RestAPI to Odata ? HOT 1
- GET Behavior when no $select query option is given? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odata.net.