I have the following DataServiceQuery working with the ADO Data Service (with the update insta...">

How to use "SelectMany" with DataServiceQuery <>

I have the following DataServiceQuery working with the ADO Data Service (with the update installed so that it starts as .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: I can not specify request parameters (orderby, where, take, skip) on one resource

As far as I can tell, I need to use the "SelectMany" version, which includes an extra lambda expression (http://msdn.microsoft.com/en-us/library/bb549040.aspx , but I cannot get this to work correctly.

Can someone show me how to properly structure the SelectMany call?

Thanks for any help.

+3
1

SelectMany , , "" .

URI, , .

URI OData Entity , (../NavigationProperty).

, :

~/Users(123)/ConsumerXRef

, (123), ConsumerXRef ().

:

~/Users(123)/ConsumerXRef/Account

ConsumerXRef , .

LINQ, - :

from u in ctx.Users
where u.ID == 123
from c in u.ConsumerXRef
select c;

, :

~/Users(123)/ConsumerXRef

:

from u in _gsc.Users
where u.UserId == myId
from c in u.ConsumerXref
where c.AccountName == "MyAccount" && c.IsActive
select x.Account;

, - - AccountName ? - URL

~/Users(123)/ConsumerXRef/Account/?$filter=AccountName eq 'MyAccount' ...

, ( ConsumerXRefs ) ConsumerXRef.

?

,

+12

Source: https://habr.com/ru/post/1732403/


All Articles