simple-odata-client/Simple.OData.Client

Filtering properties of derived types does not work

habex-ch opened this issue · 0 comments

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.