WCF Data Service expand function need help
-
Thursday, January 05, 2012 12:30 PM
Hi,
i am having 3 tables Contents, Tags and ContentTags.
Where ContentTags having PK of Contents and Tags as Fk.
Now my requirement is to populate all the contents with its ContentTags details along with the tags details where Tags ='<any tag>'
currently i am able to populate all the content by using below URI-
https://myservice/WNADataService.svc/Contents()?$expand=ContentTags,ContentTags/Tag
But i am not able to get all the contents for a specific Tag.
or can we have something like this
http://services.odata.org/Northwind/Northwind.svc/Orders()/Customer where orderid in (4,5,6,7,8)
and also can we have something like this
http://services.odata.org/Northwind/Northwind.svc/Orders(1,2,3,4,5)/Customer
please help me..
- Edited by Rahul71 Thursday, January 05, 2012 1:20 PM
All Replies
-
Saturday, January 07, 2012 11:29 AMModerator
Hi dexter71,
Welcome!
We will do some more pending research about your problem and come back as soon as possible, Thanks for understanding.
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

-
Wednesday, January 11, 2012 6:58 AMModerator
Hi dexter71,
>>http://services.odata.org/Northwind/Northwind.svc/Orders(1,2,3,4,5)/Customer
Please try: http://services.odata.org/Northwind/Northwind.svc/Orders()?$filter=orderid lt 6&$expand=Customer
I'd like to share a way to get the query URI:
1. Create a client(Console application)
2. Add service reference to console application.
3. Write the query, for example:
var db = new HospitalContext(new Uri(@"http://localhost:4490/HospitalService.svc")); var q = from c in db.Patients.Expand("LabResults") where c.Id < 3 select c;
4. set break point after the query, press F5 to debug.
5. you can easy watch the query URI in watch window
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

- Marked As Answer by Alan_chenModerator Monday, January 30, 2012 8:11 AM
-
Tuesday, January 17, 2012 10:24 PM
Hi dexter71,
We don't currently support the ability to filter entity sets which come from expansions. In the future, you'll be able to do this with the "any" keyword described here: http://www.odata.org/blog/2011/2/15/even-more-any-and-all.
In your case, you may want to structure the query so that you get the tags first, like this:
https://myservice/WNADataService.svc/Tags()?$filter=tagvalue eq 'some specific tag'&$expand=Contents
(assuming you have an association from a tag to the Contents table)
Hope this helps,
Jen
- Marked As Answer by Alan_chenModerator Monday, January 30, 2012 8:11 AM
-
Friday, January 20, 2012 10:44 AM
Hi Dexter,
Not sure if you managed to resolve your problems but, in the case you haven't or anybody else stumbles on this question with the same problem:
To expand on a filtered list, I believe the Odata query should be as Alan said. I haven't come across an 'In' function for OData, if you want to extract a user selected list of items I believe the filter needs to besomething like
http://services.odata.org/Northwind/Northwind.svc/Orders()?$filter=OrderID eq 1031 or OrderID eq 34 or OrderID eq 192&$expand=Customer
I'm not entirely sure on what the problem is with your Content/Tags scenario, are you after something like this
https://myservice/WNADataService.svc/Contents()?$expand=ContentTags/Tag/Content
?
- Marked As Answer by Alan_chenModerator Monday, January 30, 2012 8:11 AM

