C# Expression Comparison
c#, lambda
Solution
You will have to decompose each Expression into all the possible inherited types (MethodCallExpression, ConditionalExpression, etc.), then walk each decomposition in parallel and check each possible parameters... It will be a little long to code... You can inspire yourself from ExpressionEqualityComparer
Problem
Let's say I have following expressions on a collection: ``` var people = new List<Person> { new Person {FullName = "Some Dude", Age = 45}, new Person {FullName = "Another Dude", Age = 28}, new Person {FullName = "Some Other Dude", Age = 36} }; var filtered = people.Where(person => person.Age > 28 && person.FullName.StartsWith("So")); var narrowlyFiltered = people.Where(person => person.Age > 36 && person.FullName.StartsWith("Some")); ``` Is there a way to compare these two expressions and deduce that second expression is subset of first one on runtime? Without enumerating or anything else. I just have expressions and I am trying to find out if these expressions intersect or contains one another.