I am moving to using the latest c# drivers and am having trouble with serialization of casts in expressions. I raised a ticket some time ago but it hasn’t really been addressed so I’m hoping for some additional help. The ticket is https://jira.mongodb.org/browse/CSHARP-4572
In summary I want to run code like the following:
Builders<IMyInterface>.Filter.Eq(x=>((MyClass)x).TestValue, 42)
The problem is that it says “Expression not supported: Convert(x)”.
In this particular simplified case I can change to using OfType to do the casting, unfortunately in my codebase queries are done to our repository just by using:
FetchAllByExpression(Func<IMyClass, bool>)
So I am really looking for a way to structure an expression such that it can be translated without a problem. Is this possible in some way?