Follow Up: Why Isn’t My Linq Query Working

My friend Bill gave me some good feedback on my last post where I talked about making sure you have some kind of value equality implementation on your business objects so Linq queries work the way you expect them to.  Bill informed me that anonymous types’ default implementation of Equals() is very similar to that of structs.  Two objects of an anonymous type are considered equals if all of their properties’ Equals() calls return true.  So if you can get away with using anonymous types in your Linq queries, things should work as expected.  Be careful, though, if you have properties in your anonymous types that are using reference equality.  If so, you may still see some strange behavior.