How to use "SelectMany" with DataServiceQuery<>
Posted
by sako73
on Stack Overflow
See other posts from Stack Overflow
or by sako73
Published on 2010-02-11T19:18:20Z
Indexed on
2010/03/26
3:33 UTC
Read the original article
Hit count: 1088
ado.net-data-services
|wcf-data-services
I have the following DataServiceQuery running agaist an ADO Data Service (with the update installed to make it run like .net 4):
DataServiceQuery<Account> q = (_gsc.Users
.Where(c => c.UserId == myId)
.SelectMany(c => c.ConsumerXref)
.Select(x => x.Account)
.Where(a => a.AccountName == "My Account" && a.IsActive)
.Select(a => a)) as DataServiceQuery<Account>;
When I run it, I get an exception: Cannot specify query options (orderby, where, take, skip) on single resource
As far as I can tell, I need to use a version of "SelectMany" that includes an additonal lambda expression (http://msdn.microsoft.com/en-us/library/bb549040.aspx), but I am not able to get this to work correctly.
Could someone show me how to properly structure the "SelectMany" call?
Thank you for any help.
© Stack Overflow or respective owner