Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
Hi Gents,

I have an OData service which is being used in an application.

In that Application I try to:
C#
DataFromService = ODataStore.MarinGlobalService.Instance.Service.Users
                    .Expand(x => x.ApplicationUsers.Where(y => !y.IsDeleted));


It leads to an error:
The expression 'x => x.ApplicationUsers.Where(y => Not(y.IsDeleted))' is not a valid expression for navigation path. The only supported operations inside the lambda expression body are MemberAccess and TypeAs. The expression must contain at least one MemberAccess and it cannot end with TypeAs.

How can I check only the IsDeleted = false are incuded in the expand result?

What I have tried:

My services has for usergroups the .Where(x => !x.IsDeleted)

C#
[EnableQuery(MaxExpansionDepth=8)]
        public IQueryable<UserGroup> GetUserGroups()
        {
            return db.UserGroups.Where(x => !x.IsDeleted);
                
        }

Still the Expand function gives me the rows of data that has IsDeleted = true.
Posted
Comments
Richard Deeming 12-Mar-20 10:39am    
Have you enabled nested filters on the server?
Nested $filter in $expand - OData | Microsoft Docs[^]

Which OData client library are you using?
Herman<T>.Instance 12-Mar-20 11:18am    
I use OData connected services

Richard Deeming 12-Mar-20 11:38am    
Based on the error message, I suspect you're using:
GitHub - OData/odata.net: ODataLib: Open Data Protocol - .NET Libraries and Frameworks[^]

(Either directly or indirectly.)

It looks like there are various issues logged on that project regarding filtered "expand" operations. I can't see anything that directly relates to your error message. It might be worth logging an issue there.
Herman<T>.Instance 12-Mar-20 11:39am    
I use a V3 protocol. I just started upgrading to v4 and retry the issue. Have the
config.Filter().Expand().Select().OrderBy().MaxTop(null).Count();
added
Herman<T>.Instance 12-Mar-20 12:12pm    
Library = Microsoft.aspnet.Odata.

Upgrading to V4 and adding the nested $filter in $expand did not help.

Any other options?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900