implementing Dynamic Linq Expressions and Entity Framework - Type Mismatch scenarios
I'm a bit lost with I'm working on a project and hit a roadblock... I'm working with a `System.InvalidCastException` when using Dynamic LINQ to build queries for my Entity Framework Core 5.0 application. I have a scenario where I need to dynamically filter a list of products based on various criteria, and Iβm using a library like System.Linq.Dynamic.Core to construct the expressions. The scenario arises when I try to filter based on a nullable boolean property, `IsAvailable`. Hereβs a simplified version of my code: ```csharp var filter = "IsAvailable == true"; var products = await _context.Products.Where(filter).ToListAsync(); ``` When executing this code, I get the behavior: `InvalidCastException: Unable to cast object of type 'System.Boolean' to type 'System.Nullable`1[System.Boolean]'.` Iβve verified that `IsAvailable` is indeed a nullable boolean in my model. I've tried wrapping the condition in `Convert.ToBoolean()` but that hasn't worked. I also ensured that the property is correctly mapped in my DbContext. I'm not sure why the dynamic expression generator is treating `true` as a non-nullable boolean. Is there a specific syntax I should be using for nullable values in Dynamic LINQ? Any guidance or examples would be greatly appreciated! I'm working on a service that needs to handle this. For context: I'm using C# on Linux. I recently upgraded to C# latest. Any ideas what could be causing this?