Is there a mechanism to compare EntityObject values for equal values in Entity Framework?

entity-framework equality

Question

Is there a simple way to compare two EntityObjects for value-equality. I simply want to check if all the database-values are the same, so I don't care if the EntityKey is different.

Is this possible built-in? Or should I just write my own method.

I guess Equals() doesn't work as I want it here?

1
4
11/23/2009 7:22:56 PM

Accepted Answer

Equals() checks for referential equality, so it wouldn't help you there.

Take a look at this question: What is the best way to compare two entity framework entities?

UPDATE 2014:
A more complete answer, in line with the current state of EF, would be that you could override the Equality operator in a code-first model to provide a check for value-equality.

3
5/23/2017 12:01:12 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow