You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to determine when a client has specified an "$expand" operation on my endpoint so that I can decided whether or not to load the data. By default, the ODataQueryOperation.Current.ContextParameters does not include querystring items that start with a "$".
Line 53 of ODataQueryProvider.cs should be changed from:
var queryStringDictionary = queryString.AllKeys.Where(p => !p.StartsWith("$")).ToDictionary(k => k, p => queryString[p]);
to
var queryStringDictionary = queryString.AllKeys.ToDictionary(k => k, p => queryString[p]);
so that we can inspect the context to determine whether the $expand operation was requested.
In fact, it would be nice to include $expand-specific properties in ODataQueryOperation itself, similar to how ProjectedProperties works.
The text was updated successfully, but these errors were encountered:
Depending on how you structure your models between first-class entities and complex types, you shouldn't really have to know whether or not $expand was passed. That said, this library was originally written and linked against an older ODataLib which only supported v2 protocol which had no support for complex types. I think if you really need to expose this functionality, there is a new class in ODataLib 5.5 -- ODataUriParser - that is intended to do this work. We're currently linked against 5.5, but not using any of this functionality yet.
EDIT: I understand what you mean now. When returning an entity from the repository, you must return the fully populated (deep) entity as you don't know the full extent of the query. If you knew that $expand was specified, you could optimize. I see - sorry, it's been a while.
I would like to determine when a client has specified an "$expand" operation on my endpoint so that I can decided whether or not to load the data. By default, the ODataQueryOperation.Current.ContextParameters does not include querystring items that start with a "$".
Line 53 of ODataQueryProvider.cs should be changed from:
var queryStringDictionary = queryString.AllKeys.Where(p => !p.StartsWith("$")).ToDictionary(k => k, p => queryString[p]);
to
var queryStringDictionary = queryString.AllKeys.ToDictionary(k => k, p => queryString[p]);
so that we can inspect the context to determine whether the $expand operation was requested.
In fact, it would be nice to include $expand-specific properties in ODataQueryOperation itself, similar to how ProjectedProperties works.
The text was updated successfully, but these errors were encountered: