Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering properties of derived types does not work #889

Open
habex-ch opened this issue Jan 3, 2023 · 0 comments
Open

Filtering properties of derived types does not work #889

habex-ch opened this issue Jan 3, 2023 · 0 comments

Comments

@habex-ch
Copy link

habex-ch commented Jan 3, 2023

Hi there,

I have something like

public class Animal { 
    public string Name { get; set; }
}

public class Dog : Animal
{
    public string Breed { get; set; }
}

Adding a filter like the following works (as it is mentioned in the Wiki):
.Filter(x => x as Dog != null)

But filtering a property of the derived entity does not:
.Filter(x => (x as Dog).Breed.Contains("Terrier"))

I am getting the following error:

NotSupportedException: Not supported expression of type System.Linq.Expressions.PropertyExpression (MemberAccess): (x As Dog).Breed
Simple.OData.Client.ODataExpression.ParseMemberExpression(Expression expression, Stack<MemberInfo> memberChain)

My final goal would be something like
.Filter(x => x.Name.Contains("Terrier") || (x as Dog).Breed.Contains("Terrier"))

The issue #622 is marked as closed, but the main examples do no work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant