Is it possible to find out if two expressions are the same?
Like given the following four expressions:
Expression<Func<int, bool>> a = x => false;
Expression<Func<int, bool>> b = x => false;
Expression<Func<int, bool>> c = x => true;
Expression<Func<int, bool>> d = x => x == 5;
Then, at least we can see that:
a == b
a != c
a != d
But can I do anything to find this out in my code?
Took a peek in the msdn library, where it says that
Equals
: Determines whether the specified Object is equal to the currentObject
. (Inherited fromObject
.)
which I guess means that at least the Expression class hasn't overrided the equals method to become Equatable? So how would you do this? Or am I asking too much here? :p
MemberInfo
involved there, I mean some method, property of field, then you can get the memberinfo first, and compute its hash – Harmonious