Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContextParameters should include more information #5

Open
mikehebert opened this issue Jun 24, 2013 · 1 comment
Open

ContextParameters should include more information #5

mikehebert opened this issue Jun 24, 2013 · 1 comment

Comments

@mikehebert
Copy link

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.

@oising
Copy link
Owner

oising commented Jun 24, 2013

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.

http://blogs.msdn.com/b/alexj/archive/2013/05/10/parsing-odata-paths-select-and-expand-using-the-odatauriparser.aspx

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants