开发者

Entity Framework: Is there a method to compare for equal values of EntityObject?

开发者 https://www.devze.com 2022-12-12 12:49 出处:网络
Is there a simple way to compare two EntityObjects for value-equality. I simply want to check if all the d开发者_JS百科atabase-values are the same, so I don\'t care if the EntityKey is different.

Is there a simple way to compare two EntityObjects for value-equality. I simply want to check if all the d开发者_JS百科atabase-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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号