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.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Error CS1061 'IQueryable<User>' does not contain a definition for 'Expand' and no accessible extension method 'Expand' accepting a first argument of type 'IQueryable<User>' could be found (are you missing a using directive or an assembly reference?)
In this way the query works but IsDeleted = true is still added
If it works, and you want to remove the sub records that contain IsDeleted = true, you can do a secondary query. The Id and UserName are the propperties I assume in the User class, you should add it based on your suitation
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
None
0 Points
3 Posts
Strange Expand behaviour
Mar 13, 2020 12:53 PM|Herman Talstra|LINK
Hi everyone,
I have an asp.net WebAPI created with OData (microsoft.aspnet.odata package). Each controller has check for the value false for the property IsDeleted
In my client I do:
In the Expand I see ApplicationUsers and UserGroups that have IsDeleted = true. Why are they getting in my result .
If I change to
I get an exception:
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 to get rid of the IsDeleted true items?
Participant
1320 Points
491 Posts
Re: Strange Expand behaviour
Mar 16, 2020 07:45 AM|jiadongm|LINK
Hi Herman,
You should change your query like below.
Best Regards,
Jiadong Meng
None
0 Points
3 Posts
Re: Strange Expand behaviour
Mar 18, 2020 08:14 AM|Herman Talstra|LINK
Hi!
Thank you for answering my question
In your style the Linq query gave errors, so I changed it to:
.Expand(x => x.ApplicationUsers)
.Expand(x => x.UserGroups)
.Where(x => x.ApplicationUsers.Any(y => !y.IsDeleted))
.Where(x => x.UserGroups.Any(z => !z.IsDeleted));
I can only test next week your solution due to #corona in the Netherlands. I'll keep you informed
In this way the query works but IsDeleted = true is still added
None
0 Points
3 Posts
Re: Strange Expand behaviour
Mar 19, 2020 10:52 AM|Herman Talstra|LINK
Leads to:
Error CS1061 'IQueryable<User>' does not contain a definition for 'Expand' and no accessible extension method 'Expand' accepting a first argument of type 'IQueryable<User>' could be found (are you missing a using directive or an assembly reference?)
Participant
1320 Points
491 Posts
Re: Strange Expand behaviour
Mar 23, 2020 03:16 AM|jiadongm|LINK
Hi Herman
Can the above codes work without any exception?
If it works, and you want to remove the sub records that contain IsDeleted = true, you can do a secondary query. The Id and UserName are the propperties I assume in the User class, you should add it based on your suitation
Best Regards,
Jiadong Meng