We have decided to require an explicit action to enable OData query support to avoid unintentional disclosure of information, e.g. if you expose your IQueryable<Employee> we don't want to enable automatic sorting on Salary to avoid disclosing that Mary is
making more money than Jane.
Anyone figured out how to wire up the new Interfaces to be able to extend the Odata support for $select etc? Apparently it is in there, just need to be able to implement it. I can't find any samples.
Is there any way to get back the total count? I see that it's just returning a json array without the total now wheras before it returned the array and totalcount etc for paging purposes.
It seems that the IStructuredQueryBuilder has been removed from the official RC packages. Have you been able to successfully use the approach suggested by marcind?
John Galt
Member
30 Points
47 Posts
Web API + OData in RC
Jun 01, 2012 02:20 PM|LINK
Is it completely gone?
Is there a way to turn it back on again?
Thanks!
XIII
All-Star
182789 Points
23485 Posts
ASPInsiders
Moderator
MVP
Re: Web API + OData in RC
Jun 01, 2012 02:41 PM|LINK
Hi,
you have to put a [Queryable] attribute on the method: http://www.asp.net/web-api/overview/web-api-routing-and-actions/paging-and-querying.
[Queryable] public IQueryable<Product> GetAllProducts() { return repository.GetAll().AsQueryable(); }Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
marcind
Contributor
3344 Points
609 Posts
Microsoft
Re: Web API + OData in RC
Jun 01, 2012 04:06 PM|LINK
Kris is correct.
We have decided to require an explicit action to enable OData query support to avoid unintentional disclosure of information, e.g. if you expose your IQueryable<Employee> we don't want to enable automatic sorting on Salary to avoid disclosing that Mary is making more money than Jane.
ASP.NET Team
@marcind
Blog
MikeWasson
Member
499 Points
79 Posts
Microsoft
Re: Web API + OData in RC
Jun 01, 2012 05:00 PM|LINK
I think that Mary might want to know about that! :-)
John Galt
Member
30 Points
47 Posts
Re: Web API + OData in RC
Jun 01, 2012 05:19 PM|LINK
:) Thanks! Found it.
Anyone figured out how to wire up the new Interfaces to be able to extend the Odata support for $select etc? Apparently it is in there, just need to be able to implement it. I can't find any samples.
raghuramn
Member
248 Points
64 Posts
Microsoft
Re: Web API + OData in RC
Jun 02, 2012 01:05 AM|LINK
There is an integration test demonstrating how to plug-in $select support.
If you have the sources you can take a look at test\System.Web.Http.Integration.Test\Query\StructuredQueryBuilderPlus.cs for the sample. If not "git clone https://git01.codeplex.com/aspnetwebstack.git" or browse the file.
John Galt
Member
30 Points
47 Posts
Re: Web API + OData in RC
Jun 04, 2012 03:25 PM|LINK
Thanks!
Is there any way to get back the total count? I see that it's just returning a json array without the total now wheras before it returned the array and totalcount etc for paging purposes.
John Galt
Member
30 Points
47 Posts
Re: Web API + OData in RC
Jun 04, 2012 03:39 PM|LINK
Also went to that file but I can't see how to invoke the class that I inherit. How do I get everything to actually use it?
marcind
Contributor
3344 Points
609 Posts
Microsoft
Re: Web API + OData in RC
Jun 05, 2012 01:26 AM|LINK
You need to register an instance of IStructuredQueryBuilder with the service provider in your configuration.
ASP.NET Team
@marcind
Blog
szilimuzsi
Member
4 Points
3 Posts
Re: Web API + OData in RC
Jun 13, 2012 08:42 AM|LINK
It seems that the IStructuredQueryBuilder has been removed from the official RC packages. Have you been able to successfully use the approach suggested by marcind?